]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
use correct entity in path for aliased class relationship
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 Oct 2021 16:31:06 +0000 (12:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 Oct 2021 16:36:42 +0000 (12:36 -0400)
commit0fff45036d2629caf41c771088866beb61e5b284
treeebb376315646196ec053198bef6ff2b834337712
parentee340d17ea45b25c063d7bfca999b7b8031ff0fe
use correct entity in path for aliased class relationship

Fixed bug in "relationship to aliased class" feature introduced at
:ref:`relationship_aliased_class` where it was not possible to create a
loader strategy option targeting an attribute on the target using the
:func:`_orm.aliased` construct directly in a second loader option, such as
``selectinload(A.aliased_bs).joinedload(aliased_b.cs)``, without explicitly
qualifying using :meth:`_orm.PropComparator.of_type` on the preceding
element of the path. Additionally, targeting the non-aliased class directly
would be accepted (inappropriately), but would silently fail, such as
``selectinload(A.aliased_bs).joinedload(B.cs)``; this now raises an error
referring to the typing mismatch.

Fixes: #7224
Change-Id: I40857c7275667dcb64f1d1fd0c8072e48758e678
doc/build/changelog/unreleased_14/7224.rst [new file with mode: 0644]
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/path_registry.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/relationships.py
test/orm/test_ac_relationships.py