]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
mark has()/any() as ORM; adjust criteria in WHERE without explicit FROM
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 8 Jan 2026 21:37:38 +0000 (16:37 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 9 Jan 2026 20:14:35 +0000 (15:14 -0500)
commit5491f251b4db55b8d60455ed56b36482e452490e
treedd7b9620d8784c99ef582e706200d4fd4f746164
parentdfd47acd45a3feb2c4876047e19bdb71b8a0221b
mark has()/any() as ORM; adjust criteria in WHERE without explicit FROM

A significant change to the ORM mechanics involved with both
:func:`.orm.with_loader_criteria` as well as single table inheritance, to
more aggressively locate WHERE criteria which should be augmented by either
the custom criteria or single-table inheritance criteria; SELECT statements
that do not include the entity within the columns clause or as an explicit
FROM, but still reference the entity within the WHERE clause, are now
covered, in particular this will allow subqueries using ``EXISTS (SELECT
1)`` such as those rendered by :meth:`.RelationshipProperty.Comparator.any`
and :meth:`.RelationshipProperty.Comparator.has`.

Fixes: #13070
Change-Id: I9afb48e1c95b9e61f4e1b6be8e4a634ed5b1df43
doc/build/changelog/unreleased_21/13070.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/sql/util.py
test/orm/inheritance/test_relationship.py
test/orm/inheritance/test_single.py
test/orm/test_relationship_criteria.py
test/orm/test_relationships.py