]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
deprecate joinedload, subqueryload with DML; use correct statement
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 9 Sep 2024 13:21:20 +0000 (09:21 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 9 Sep 2024 23:13:45 +0000 (19:13 -0400)
commitfb02aa96c24204cb317f6369d74e85e903a6d978
tree71aaa6080797f87d0f2ea44a6d28f14538439fd3
parent0a4b2a8ea32d2584131d45138c0c074f2b3d3703
deprecate joinedload, subqueryload with DML; use correct statement

An ORM exception is raised if :func:`_orm.joinedload` or
:func:`_orm.subqueryload` are used as a top level option against a
statement that is not a SELECT statement, such as with an
``insert().returning()``.   There are no JOINs in INSERT statements nor is
there a "subquery" that can be repurposed for subquery eager loading, and
for UPDATE/DELETE joinedload does not support these either, so it is never
appropriate for this use to pass silently.

Fixed issue where using eager loaders such as :func:`_orm.selectinload`
with additional criteria in combination with ORM DML such as
:func:`_sql.insert` with RETURNING would not correctly set up internal
contexts required for caching to work correctly, leading to incorrect
results.

Fixes: #11853
Fixes: #11855
Change-Id: Ibbf46ba4f83e472441074c3257e23388e0fcec37
(cherry picked from commit 9ea449bf41006e94273186a974d3a1b091a0552a)
doc/build/changelog/unreleased_20/11853.rst [new file with mode: 0644]
doc/build/changelog/unreleased_20/11855.rst [new file with mode: 0644]
lib/sqlalchemy/orm/bulk_persistence.py
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/strategy_options.py
test/orm/dml/test_bulk_statements.py