From: Mike Bayer Date: Tue, 30 Aug 2022 14:47:24 +0000 (-0400) Subject: include TableClause.schema in cache key X-Git-Tag: rel_1_4_41~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12547f963363eefbc9e22bc9b12243971551d89e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git include TableClause.schema in cache key 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) --- diff --git a/doc/build/changelog/unreleased_14/8441.rst b/doc/build/changelog/unreleased_14/8441.rst new file mode 100644 index 0000000000..963850a109 --- /dev/null +++ b/doc/build/changelog/unreleased_14/8441.rst @@ -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. + diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 8379e1ca73..95e13f0810 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -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 diff --git a/test/sql/test_compare.py b/test/sql/test_compare.py index 26340d21d4..f73e9864d3 100644 --- a/test/sql/test_compare.py +++ b/test/sql/test_compare.py @@ -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}), ),