Some drivers convert pg uuid to UUID by themselves

This commit is contained in:
Hong Minhee
2015-07-10 14:51:25 +09:00
parent 6f1b61762f
commit c1c2b40b38

View File

@@ -73,6 +73,10 @@ class UUIDType(types.TypeDecorator, ScalarCoercible):
return value return value
if self.native and dialect.name == 'postgresql': if self.native and dialect.name == 'postgresql':
if isinstance(value, uuid.UUID):
# Some drivers convert PostgreSQL's uuid values to
# Python's uuid.UUID objects by themselves
return value
return uuid.UUID(value) return uuid.UUID(value)
return uuid.UUID(bytes=value) if self.binary else uuid.UUID(value) return uuid.UUID(bytes=value) if self.binary else uuid.UUID(value)