summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-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"