]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
ensure _ORMJoin transfers parententity from left side
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Oct 2022 02:59:51 +0000 (22:59 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Oct 2022 03:10:00 +0000 (23:10 -0400)
commit92468b1806f8e3dfd1e1b13ba2c85aa936704339
treed0c2d40a278cdc196228f842ae75c4a1132a1050
parentdbae24ab4c5f1e02e81d7211c94e1c7d9fc3562f
ensure _ORMJoin transfers parententity from left side

Fixed bug involving :class:`.Select` constructs which used a combination of
:meth:`.Select.select_from` with an ORM entity followed by
:meth:`.Select.join` against the entity sent in
:meth:`.Select.select_from`, as well as using plain
:meth:`.Select.join_from`, which when combined with a columns clause that
didn't explicitly include that entity would then cause "automatic WHERE
criteria" features such as the IN expression required for a single-table
inheritance subclass, as well as the criteria set up by the
:func:`_orm.with_loader_criteria` option, to not be rendered for that
entity. The correct entity is now transferred to the :class:`.Join` object
that's generated internally, so that the criteria against the left
side entity is correctly added.

Fixes: #8721
Change-Id: I8266430063e2c72071b7262fdd5ec5079fbcba3e
(cherry picked from commit 54ecc0fde9851f551c6e467b58d5bf7c4135e0ba)
doc/build/changelog/unreleased_14/8721.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/util.py
test/orm/inheritance/test_single.py
test/orm/test_relationship_criteria.py