diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2022-04-18 13:07:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-04-21 09:51:28 -0400 |
commit | 408c936c77c6aaeceab0e0b001ed745ceb9d19d4 (patch) | |
tree | 3f2508b46b206cd5f2e06cbd4490e46438f24da8 /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | a8b2fbb55c6de302b053b4309c6e53cd7f748448 (diff) | |
download | sqlalchemy-408c936c77c6aaeceab0e0b001ed745ceb9d19d4.tar.gz |
Implement UUID.python_type
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
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 6c3bc4e7c..5d1298cf7 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1815,6 +1815,10 @@ class UUID(sqltypes.TypeEngine): return process + @property + def python_type(self): + return _python_UUID if self.as_uuid else str + PGUuid = UUID |