]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
include TableClause.schema in cache key
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Aug 2022 14:47:24 +0000 (10:47 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Aug 2022 14:47:59 +0000 (10:47 -0400)
Fixed issue where use of the :func:`_sql.table` construct, passing a string
for the :paramref:`_sql.table.schema` parameter, would fail to take the
"schema" string into account when producing a cache key, thus leading to
caching collisions if multiple, same-named :func:`_sql.table` constructs
with different schemas were used.

Fixes: #8441
Change-Id: Ic4b55b3e8ec53b4c88ba112691bdf60ea1d4c448
(cherry picked from commit 613642d9639f47ad11ab62a3fa71f6132edbaa0d)

doc/build/changelog/unreleased_14/8441.rst [new file with mode: 0644]
lib/sqlalchemy/sql/selectable.py
test/sql/test_compare.py

diff --git a/doc/build/changelog/unreleased_14/8441.rst b/doc/build/changelog/unreleased_14/8441.rst
new file mode 100644 (file)
index 0000000..963850a
--- /dev/null
@@ -0,0 +1,10 @@
+.. change::
+    :tags: bug, sql
+    :tickets: 8441
+
+    Fixed issue where use of the :func:`_sql.table` construct, passing a string
+    for the :paramref:`_sql.table.schema` parameter, would fail to take the
+    "schema" string into account when producing a cache key, thus leading to
+    caching collisions if multiple, same-named :func:`_sql.table` constructs
+    with different schemas were used.
+
index 8379e1ca7350d763245c7ddf330f47bd8c363410..95e13f0810d0121e1f37f6c072f9b19582324c30 100644 (file)
@@ -2685,6 +2685,7 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause):
             InternalTraversal.dp_fromclause_canonical_column_collection,
         ),
         ("name", InternalTraversal.dp_string),
+        ("schema", InternalTraversal.dp_string),
     ]
 
     named_with_column = True
index 26340d21d45f0520b1da19e1b9a93e5f31e096e6..f73e9864d37691e64c969d0c0fc8d9f96a65acf4 100644 (file)
@@ -266,6 +266,8 @@ class CoreFixtures(object):
         ),
         lambda: (
             table("a", column("x"), column("y")),
+            table("a", column("x"), column("y"), schema="q"),
+            table("a", column("x"), column("y"), schema="y"),
             table("a", column("x"), column("y"))._annotate({"orm": True}),
             table("b", column("x"), column("y"))._annotate({"orm": True}),
         ),