mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-08-05 20:40:14 +03:00
UUIDField compatibility with Python 3
This commit is contained in:
parent
da87a151df
commit
840b29499a
|
@ -461,8 +461,10 @@ class UUIDField(Field):
|
||||||
def to_python(self, value, timezone_in_use):
|
def to_python(self, value, timezone_in_use):
|
||||||
if isinstance(value, UUID):
|
if isinstance(value, UUID):
|
||||||
return value
|
return value
|
||||||
|
elif isinstance(value, binary_type):
|
||||||
|
return UUID(bytes=value)
|
||||||
elif isinstance(value, string_types):
|
elif isinstance(value, string_types):
|
||||||
return UUID(bytes=value) if len(value) == 16 else UUID(value)
|
return UUID(value)
|
||||||
elif isinstance(value, integer_types):
|
elif isinstance(value, integer_types):
|
||||||
return UUID(int=value)
|
return UUID(int=value)
|
||||||
elif isinstance(value, tuple):
|
elif isinstance(value, tuple):
|
||||||
|
|
|
@ -28,7 +28,7 @@ class UUIDFieldsTest(unittest.TestCase):
|
||||||
'{12345678-1234-5678-1234-567812345678}',
|
'{12345678-1234-5678-1234-567812345678}',
|
||||||
'12345678123456781234567812345678',
|
'12345678123456781234567812345678',
|
||||||
'urn:uuid:12345678-1234-5678-1234-567812345678',
|
'urn:uuid:12345678-1234-5678-1234-567812345678',
|
||||||
'\x12\x34\x56\x78'*4,
|
b'\x12\x34\x56\x78'*4,
|
||||||
(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678),
|
(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678),
|
||||||
0x12345678123456781234567812345678,
|
0x12345678123456781234567812345678,
|
||||||
UUID(int=0x12345678123456781234567812345678),
|
UUID(int=0x12345678123456781234567812345678),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user