]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Join key_constraints on schema as well for SQL server get_fks
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 30 Aug 2017 16:25:57 +0000 (12:25 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 30 Aug 2017 16:25:57 +0000 (12:25 -0400)
Fixed bug where the SQL Server dialect could pull columns from multiple
schemas when reflecting a self-referential foreign key constraint, if
multiple schemas contained a constraint of the same name against a
table of the same name.

Tests are part of standard suite already (CI has been disabled)

Change-Id: I04ff4a5dea9b82c8e517b3700a28fe994b5550f3
Fixes: #4060
doc/build/changelog/unreleased_12/4060.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py

diff --git a/doc/build/changelog/unreleased_12/4060.rst b/doc/build/changelog/unreleased_12/4060.rst
new file mode 100644 (file)
index 0000000..f834430
--- /dev/null
@@ -0,0 +1,9 @@
+.. change::
+    :tags: bug, mssql
+    :tickets: 4060
+
+    Fixed bug where the SQL Server dialect could pull columns from multiple
+    schemas when reflecting a self-referential foreign key constraint, if
+    multiple schemas contained a constraint of the same name against a
+    table of the same name.
+
index 05381d671ea8a5130f0b7a0056e678638f82f805..08405e040bcf60e842dd76e1f1bfc059df81712c 100644 (file)
@@ -2151,6 +2151,7 @@ class MSDialect(default.DefaultDialect):
                         RR.c.delete_rule],
                        sql.and_(C.c.table_name == tablename,
                                 C.c.table_schema == owner,
+                                R.c.table_schema == C.c.table_schema,
                                 C.c.constraint_name == RR.c.constraint_name,
                                 R.c.constraint_name ==
                                 RR.c.unique_constraint_name,