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/base.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/base.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 5e81586b4..878693866 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -3423,10 +3423,14 @@ class PGDialect(default.DefaultDialect): ) coltype = sqltypes.NULLTYPE - # If a zero byte (''), then not a generated column. - # Otherwise, s = stored. (Other values might be added in the future.) - if generated: - computed = dict(sqltext=default, persisted=generated == "s") + # If a zero byte or blank string depending on driver (is also absent + # for older PG versions), then not a generated column. Otherwise, s = + # stored. (Other values might be added in the future.) + # + if generated not in (None, "", b"\x00"): + computed = dict( + sqltext=default, persisted=generated in ("s", b"s") + ) default = None else: computed = None |