Implemented :attr:`_postgresql.UUID.python_type` attribute for the
:class:`_postgresql.UUID` type object. The attribute will return either
``str`` or ``uuid.UUID`` based on the :paramref:`_postgresql.UUID.as_uuid`
parameter setting. Previously, this attribute was unimplemented. Pull
request courtesy Alex Grönholm.
Fixes: #7943
Closes: #7944
Change-Id: Ic4fbaeee134d586b08339801968e787cc7e14285
--- /dev/null
+.. change::
+ :tags: bug, postgresql
+ :tickets: 7943
+
+ Implemented :attr:`_postgresql.UUID.python_type` attribute for the
+ :class:`_postgresql.UUID` type object. The attribute will return either
+ ``str`` or ``uuid.UUID`` based on the :paramref:`_postgresql.UUID.as_uuid`
+ parameter setting. Previously, this attribute was unimplemented. Pull
+ request courtesy Alex Grönholm.
\ No newline at end of file
return process
+ @property
+ def python_type(self):
+ return _python_UUID if self.as_uuid else str
+
PGUuid = UUID
)
eq_(v1.fetchone()[0], value1)
+ def test_python_type(self):
+ eq_(postgresql.UUID(as_uuid=True).python_type, uuid.UUID)
+ eq_(postgresql.UUID(as_uuid=False).python_type, str)
+
class HStoreTest(AssertsCompiledSQL, fixtures.TestBase):
__dialect__ = "postgresql"