]> 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:08 +0000 (13:17 +0000)
commit5e77d544893da200d6c770d9bd34c86e33eab293
tree66ec6b55a736fdd4e1f3f444b99fc3e28f130253
parent156fef61135a55c6ad17765b64155801f1dbea66
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
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