[Sqlalchemy-tickets] Issue #4016: Support UUID on pg8000 (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Donald S. <iss...@bi...> - 2017-06-21 19:29:02
|
New issue 4016: Support UUID on pg8000 https://bitbucket.org/zzzeek/sqlalchemy/issues/4016/support-uuid-on-pg8000 Donald Stufft: It would be really awesome if the PostgreSQL support for UUIDs worked on pg8000. It appears like this should be relatively simple to do since pg8000 supports UUIDs, the main thing that needs changed is the result processor needs to not pass an already existing UUID object into the Python uuid.UUID class, and instead just return it. I worked around this locally by simply doing: ``` from sqlalchemy.dialects.postgresql import UUID as _UUID class UUID(_UUID): def result_processor(self, dialect, coltype): if self.as_uuid: _process = super().result_processor(dialect, coltype) def process(value): if isinstance(value, uuid.UUID): return value return _process(value) return process else: return None ``` Which seems to work to me, but I haven't dug into it too deeply to see if there is a reason why it is the way it is. |