]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Reflect PK of referred table if referred columns not present
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Aug 2019 17:03:49 +0000 (13:03 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Aug 2019 20:34:48 +0000 (16:34 -0400)
commitf06c6ba67303e5c75d8ad044494193d8f97b2e2e
treefdbc44d40171a12dc64ae65ad85dab728e900350
parent2051fa2ce9e724e6e77e19067d27d2660e7cd74a
Reflect PK of referred table if referred columns not present

Fixed bug where a FOREIGN KEY that was set up to refer to the parent table
by table name only without the column names would not correctly be
reflected as far as setting up the "referred columns", since SQLite's
PRAGMA does not report on these columns if they weren't given explicitly.
For some reason this was harcoded to assume the name of the local column,
which might work for some cases but is not correct. The new approach
reflects the primary key of the referred table and uses the constraint
columns list as the referred columns list, if the remote column(s) aren't
present in the reflected pragma directly.

Fixes: #4810
Change-Id: I7789f83d68845ae197a782080af8ec64a7bf48cc
doc/build/changelog/unreleased_13/4810.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/sqlite/base.py
test/dialect/test_sqlite.py