]> 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:01 +0000 (11:11 -0400)
commit652f610a35ca0ba5286b2603dd1de84528262ae2
tree79ffaad497990a15d50b0e1f12073b4b521ca0b8
parent115e941a561f2459ccd1d09c969346a0fa21f8fc
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
doc/build/changelog/unreleased_20/12907.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
test/dialect/mssql/test_reflection.py