From: Gord Thompson Date: Mon, 7 Oct 2024 12:31:22 +0000 (-0600) Subject: Apply fix to reflection of table comments X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c48094cbde3cbfaaed0b137ced4887bef14dc29;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Apply fix to reflection of table comments Fixes: #11961 Change-Id: Ia3e704973a17cdf5c45bb5b8127435ee562c7d15 --- diff --git a/doc/build/changelog/unreleased_20/11961.rst b/doc/build/changelog/unreleased_20/11961.rst new file mode 100644 index 0000000000..c6ffceb036 --- /dev/null +++ b/doc/build/changelog/unreleased_20/11961.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, postgresql, reflection + :tickets: 11961 + + Fixed bug in reflection of table comments where unrelated text would be + returned if an entry in the pg_description table happened to share the + same oid (objoid) as the table being reflected. \ No newline at end of file diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 4b9f2f0150..86357ccbb4 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -4689,6 +4689,8 @@ class PGDialect(default.DefaultDialect): pg_catalog.pg_class.c.oid == pg_catalog.pg_description.c.objoid, pg_catalog.pg_description.c.objsubid == 0, + pg_catalog.pg_description.c.classoid + == sql.func.cast("pg_catalog.pg_class", REGCLASS), ), ) .where(self._pg_class_relkind_condition(relkinds))