1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Used bytes.hex() and bytes.fromhex() to simplify.

This commit is contained in:
Sergey Fedoseev
2017-11-23 00:25:32 +05:00
committed by Tim Graham
parent 3f237c1a5b
commit 93cdd07e8f
6 changed files with 11 additions and 23 deletions

View File

@@ -1,11 +1,9 @@
import binascii
import copy
import datetime
import re
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.utils import DatabaseError
from django.utils.encoding import force_text
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
@@ -25,7 +23,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
elif isinstance(value, str):
return "'%s'" % value.replace("\'", "\'\'")
elif isinstance(value, (bytes, bytearray, memoryview)):
return "'%s'" % force_text(binascii.hexlify(value))
return "'%s'" % value.hex()
elif isinstance(value, bool):
return "1" if value else "0"
else: