summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/baked.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-10-14 17:06:07 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-10-17 11:28:36 -0400
commitae7d2837b3c5ae3fd6e9dad6b14a26abb32cfee5 (patch)
tree364dc06116db3131c4dc0f70ee365b1b440f6be7 /lib/sqlalchemy/ext/baked.py
parent4684cfb50836dc57107e49d4a78a8889c40d9662 (diff)
downloadsqlalchemy-ae7d2837b3c5ae3fd6e9dad6b14a26abb32cfee5.tar.gz
Assemble "don't joinedload other side" rule using query._current_path
Discovered during testing for [ticket:3822], the rule added for [ticket:1495] will fail if the source object has propagated options set up, which add elements to query._current_path. Fixes: #3824 Change-Id: I3d96c96fee5f9b247f739d2136d18681ac61f2fe
Diffstat (limited to 'lib/sqlalchemy/ext/baked.py')
-rw-r--r--lib/sqlalchemy/ext/baked.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py
index 3ca94925e..2f658edf3 100644
--- a/lib/sqlalchemy/ext/baked.py
+++ b/lib/sqlalchemy/ext/baked.py
@@ -467,11 +467,15 @@ class BakedLazyLoader(strategies.LazyLoader):
if rev.direction is interfaces.MANYTOONE and \
rev._use_get and \
not isinstance(rev.strategy, strategies.LazyLoader):
+
q.add_criteria(
lambda q:
q.options(
- strategy_options.Load(
- rev.parent).baked_lazyload(rev.key)))
+ strategy_options.Load.for_existing_path(
+ q._current_path[rev.parent]
+ ).baked_lazyload(rev.key)
+ )
+ )
lazy_clause, params = self._generate_lazy_clause(state, passive)