summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-10-29 20:08:25 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-10-30 09:41:51 -0400
commit99e7afb4b2d82baff80f5d1fe1b2d1b21cbbec09 (patch)
treec8f655eb7d97489ed7ec35baae22f0406d99128f /lib/sqlalchemy/orm
parented7bef700477ac85819040478ce2f2cca78c5700 (diff)
downloadsqlalchemy-99e7afb4b2d82baff80f5d1fe1b2d1b21cbbec09.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/strategies.py10
1 files changed, 7 insertions, 3 deletions
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=<from object> 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"