]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Fix subqueryload losing .and_() criteria when combined with of_type()
authorArya Rizky <algojogacor@users.noreply.github.com>
Tue, 12 May 2026 19:08:02 +0000 (15:08 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 May 2026 22:06:55 +0000 (18:06 -0400)
commitcf3cfa307f5b8cdfbd47b104db38c193503de1c8
tree667333900e993439f699b334ea12d4ec46a807fd
parent808fd28297f36bf932443bae77ca5bb16bcbd4dd
Fix subqueryload losing .and_() criteria when combined with of_type()

Fixed issue where :func:`_orm.subqueryload` combined with
:meth:`.PropComparator.of_type` and :meth:`.PropComparator.and_` would
silently drop the additional filter criteria, causing all related objects
to be loaded instead of only those matching the filter.  The
:class:`.LoaderCriteriaOption` was being constructed against the base
entity rather than the effective entity indicated by
:meth:`.PropComparator.of_type`.  Pull request courtesy Arya Rizky.

Fixes: #13207
Closes: #13290
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13290
Pull-request-sha: b7a8617cdee3757f4af4abdb4ff0090d69bb1fb5

Change-Id: I2c24652ec112511deaf39dbb9d6197e2097904ed
doc/build/changelog/unreleased_20/13207.rst [new file with mode: 0644]
lib/sqlalchemy/orm/strategies.py
test/orm/test_subquery_relations.py