]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Apply fix to reflection of table comments
authorGord Thompson <gord@gordthompson.com>
Mon, 7 Oct 2024 12:31:22 +0000 (06:31 -0600)
committerGord Thompson <gord@gordthompson.com>
Tue, 8 Oct 2024 12:34:20 +0000 (06:34 -0600)
Fixes: #11961
Change-Id: Ia3e704973a17cdf5c45bb5b8127435ee562c7d15
(cherry picked from commit 5c48094cbde3cbfaaed0b137ced4887bef14dc29)

doc/build/changelog/unreleased_20/11961.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py

diff --git a/doc/build/changelog/unreleased_20/11961.rst b/doc/build/changelog/unreleased_20/11961.rst
new file mode 100644 (file)
index 0000000..c6ffceb
--- /dev/null
@@ -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
index 4ab3ca24d16a76268116408ce1bec29228d3e6f8..19af90961c9b496add1a49b67f2e4a74a7a7b6fe 100644 (file)
@@ -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))