]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
correct for FK reflecting on PK / index col at the same time
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Oct 2025 15:09:59 +0000 (11:09 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Oct 2025 15:11:07 +0000 (11:11 -0400)
commit5bc670f6bac89a6e06b69cb38d72c0fa796c373c
tree994866a7a578ea44cd1ebb7a025180eaf281b2dd
parentded22e298a1a13084c42c3f8a18e3a8ea9781d68
correct for FK reflecting on PK / index col at the same time

Fixed issue in the MSSQL dialect's foreign key reflection query where
duplicate rows could be returned when a foreign key column and its
referenced primary key column have the same name, and both the referencing
and referenced tables have indexes with the same name. This resulted in an
"ForeignKeyConstraint with duplicate source column references are not
supported" error when attempting to reflect such tables. The query has been
corrected to exclude indexes on the child table when looking for unique
indexes referenced by foreign keys.

Fixes: #12907
Change-Id: I435d4cf3bfa9e861cbb5e1e5c8c81bd59c9a9d58
(cherry picked from commit 652f610a35ca0ba5286b2603dd1de84528262ae2)
doc/build/changelog/unreleased_20/12907.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
test/dialect/mssql/test_reflection.py