diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-16 08:26:14 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-16 10:44:37 -0400 |
commit | 362c9277b2d4d27cbcff359ba29c1e71005fed18 (patch) | |
tree | cfb401b17cd52da632ffe5a8e4231c063c87c2bf /lib/sqlalchemy/dialects/postgresql/asyncpg.py | |
parent | 8ebc8184392e20727748cd1405245e527f17e111 (diff) | |
download | sqlalchemy-362c9277b2d4d27cbcff359ba29c1e71005fed18.tar.gz |
Don't change asyncpg's "char" codec
This codec was used to ensure the "pg_attribute.generated"
column comes back as a string and not bytes, matching how
other PG drivers treat this datatype. However, this breaks
asyncpg's internal implementation of set_type_codec going forward
and the "char" datatype is actually a bytes in any case.
So at the moment it appears psycopg2/pg8000 are broken for mis-treatment
of the datatype and asyncpg is broken in that it was allowing
us to change a codec that it appears to rely upon internally.
Fixes: #5586
Change-Id: I937eba315904721aa4e2726b95432910a8affe5f
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/asyncpg.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/asyncpg.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index 780e23844..6fa1dd78b 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -486,28 +486,13 @@ class AsyncAdapt_asyncpg_connection: async def _setup_type_codecs(self): """set up type decoders at the asyncpg level. - this is first to accommodate the "char" value of - pg_catalog.pg_attribute.attgenerated being returned as bytes. - Even though the doc at - https://magicstack.github.io/asyncpg/current/usage.html#type-conversion - claims "char" is returned as "str", it looks like this is actually - the 'bpchar' datatype, blank padded. 'char' seems to be some - more obscure type (oid 18) and asyncpg codes this to bytea: - https://github.com/MagicStack/asyncpg/blob/master/asyncpg/protocol/ - codecs/pgproto.pyx#L26 - - all the other drivers treat this as a string. + these are set_type_codec() calls to normalize + There was a tentative decoder for the "char" datatype here + to have it return strings however this type is actually a binary + type that other drivers are likely mis-interpreting. """ - await self._connection.set_type_codec( - "char", - schema="pg_catalog", - encoder=lambda value: value, - decoder=lambda value: value, - format="text", - ) - def _handle_exception(self, error): if not isinstance(error, AsyncAdapt_asyncpg_dbapi.Error): exception_mapping = self.dbapi._asyncpg_error_translate |