]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Run PK/FK sync for multi-level inheritance w/ no intermediary update
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 12 Jun 2019 17:15:59 +0000 (13:15 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 12 Jun 2019 18:00:49 +0000 (14:00 -0400)
commit3f7840c2ade87e415c24c69ac5d0494d294750e0
treeb866b6941dc5f764b94f7b5a0777c9cd3c605dc8
parentb0bf421f1b12eeedd77ec6c39df8e5e6cc1fcc3f
Run PK/FK sync for multi-level inheritance w/ no intermediary update

Also fix DetectKeySwitch for intermediary class relationship

Fixed a series of related bugs regarding joined table inheritance more than
two levels deep, in conjunction with modification to primary key values,
where those primary key columns are also linked together in a foreign key
relationship as is typical for joined table inheritance.  The intermediary
table in a  three-level inheritance hierachy will now get its UPDATE if
only the primary key value has changed and passive_updates=False (e.g.
foreign key constraints not being enforced), whereas before it would be
skipped; similarly, with passive_updates=True (e.g. ON UPDATE  CASCADE in
effect), the third-level table will not receive an UPDATE statement as was
the case earlier which would fail since CASCADE already modified it.   In a
related issue, a relationship linked to a three-level inheritance hierarchy
on the primary key of an intermediary table of a joined-inheritance
hierarchy will also correctly have its foreign key column updated when the
parent object's primary key is modified, even if that parent object is a
subclass of the linked parent class, whereas before these classes would
not be counted.

Fixes: #4723
Change-Id: Idc408ead67702068e64d583a15149dd4beeefc24
doc/build/changelog/unreleased_13/4723.rst [new file with mode: 0644]
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/persistence.py
test/orm/test_naturalpks.py