]> 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:35:07 +0000 (16:35 -0400)
commitd2f5fe6ad40d607df4b9a3645ed851881b61a564
tree289d9e0da44c6a8cc3a5f79da9a9eb11921f73e4
parentd1d15c9d6060d5ea7529256e830d5134a9a8f91a
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
(cherry picked from commit f06c6ba67303e5c75d8ad044494193d8f97b2e2e)
doc/build/changelog/unreleased_13/4810.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/sqlite/base.py
test/dialect/test_sqlite.py