Merge pull request #155 from spoqa/fix-uuid-result-type

Some drivers convert uuid values to uuid.UUID by themselves
This commit is contained in:
Konsta Vesterinen
2015-07-10 21:16:47 +03:00

View File

@@ -73,6 +73,10 @@ class UUIDType(types.TypeDecorator, ScalarCoercible):
return value
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(bytes=value) if self.binary else uuid.UUID(value)