From 99e7afb4b2d82baff80f5d1fe1b2d1b21cbbec09 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 29 Oct 2022 20:08:25 -0400 Subject: fix test for same mapper to use "isa" Fixed issue in joined eager loading where an assertion fail would occur with a particular combination of outer/inner joined eager loads in conjunction with an inherited subclass mapper as the middle target. Fixes: #8738 Change-Id: I4909e7518302cbb82046e0425abbbdc8eb1c0146 --- lib/sqlalchemy/orm/strategies.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index c381b4ba7..b65774f0a 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -2541,6 +2541,11 @@ class JoinedLoader(AbstractRelationshipLoader): self, path, join_obj, clauses, onclause, extra_criteria, splicing=False ): + # recursive fn to splice a nested join into an existing one. + # splicing=False means this is the outermost call, and it + # should return a value. splicing= is the recursive + # form, where it can return None to indicate the end of the recursion + if splicing is False: # first call is always handed a join object # from the outside @@ -2555,7 +2560,7 @@ class JoinedLoader(AbstractRelationshipLoader): splicing, ) elif not isinstance(join_obj, orm_util._ORMJoin): - if path[-2] is splicing: + if path[-2].isa(splicing): return orm_util._ORMJoin( join_obj, clauses.aliased_insp, @@ -2566,7 +2571,6 @@ class JoinedLoader(AbstractRelationshipLoader): _extra_criteria=extra_criteria, ) else: - # only here if splicing == True return None target_join = self._splice_nested_inner_join( @@ -2589,7 +2593,7 @@ class JoinedLoader(AbstractRelationshipLoader): ) if target_join is None: # should only return None when recursively called, - # e.g. splicing==True + # e.g. splicing refers to a from obj assert ( splicing is not False ), "assertion failed attempting to produce joined eager loads" -- cgit v1.2.1