]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
restore transfer of mapper.local_table to DML for some cases
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 20 Jul 2024 02:59:35 +0000 (22:59 -0400)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Mon, 29 Jul 2024 13:17:12 +0000 (13:17 +0000)
commitd69b2a0a017bcf76ef3fdebf9b5af62714f73c3b
tree85693e693fa09e4957a6ef803931632a44cfe94e
parent6ed8e6920ad9d29cd32b29ad237caf7b8d52bcf6
restore transfer of mapper.local_table to DML for some cases

Fixed regression appearing in 2.0.21 caused by :ticket:`10279` where using
a :func:`_sql.delete` or :func:`_sql.update` against an ORM class that is
the base of an inheritance hierarchy, while also specifying that subclasses
should be loaded polymorphically, would leak the polymorphic joins into the
UPDATE or DELETE statement as well creating incorrect SQL.

This re-introduces logic to set the `.table` of an ORM update or delete
back to `mapper.local_table` that was removed in d18ccdc997185b74 by
:ticket:`10279`; the logic is qualified to only take place for a
statement that's directly against a mapper and not one that's against
an aliased object.

Fixes: #11625
Change-Id: Ia228c99809370733f111925554167e39bcd6be1d
(cherry picked from commit e82660aba0b9ced0b3c65fd8fc4496e4e371fce0)
doc/build/changelog/unreleased_20/11625.rst [new file with mode: 0644]
lib/sqlalchemy/orm/bulk_persistence.py
test/orm/dml/test_update_delete_where.py