summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-03-28 11:00:37 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-06-05 11:27:00 -0400
commitbb6a1f690d4a749df44a1ef329b66f71205968fe (patch)
tree90aac9e592df3a769f5397f84a14b911e4cb52f1 /lib/sqlalchemy/ext
parent6bb97495baa640c6f03d1b50affd664cb903dee3 (diff)
downloadsqlalchemy-bb6a1f690d4a749df44a1ef329b66f71205968fe.tar.gz
selectin polymorphic loading
Added a new style of mapper-level inheritance loading "polymorphic selectin". This style of loading emits queries for each subclass in an inheritance hierarchy subsequent to the load of the base object type, using IN to specify the desired primary key values. Fixes: #3948 Change-Id: I59e071c6142354a3f95730046e3dcdfc0e2c4de5
Diffstat (limited to 'lib/sqlalchemy/ext')
-rw-r--r--lib/sqlalchemy/ext/baked.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py
index ba3c2aed0..c0fe963ac 100644
--- a/lib/sqlalchemy/ext/baked.py
+++ b/lib/sqlalchemy/ext/baked.py
@@ -154,7 +154,7 @@ class BakedQuery(object):
self._spoiled = True
return self
- def _add_lazyload_options(self, options, effective_path):
+ def _add_lazyload_options(self, options, effective_path, cache_path=None):
"""Used by per-state lazy loaders to add options to the
"lazy load" query from a parent query.
@@ -166,13 +166,16 @@ class BakedQuery(object):
key = ()
- if effective_path.path[0].is_aliased_class:
+ if not cache_path:
+ cache_path = effective_path
+
+ if cache_path.path[0].is_aliased_class:
# paths that are against an AliasedClass are unsafe to cache
# with since the AliasedClass is an ad-hoc object.
self.spoil()
else:
for opt in options:
- cache_key = opt._generate_cache_key(effective_path)
+ cache_key = opt._generate_cache_key(cache_path)
if cache_key is False:
self.spoil()
elif cache_key is not None:
@@ -181,7 +184,7 @@ class BakedQuery(object):
self.add_criteria(
lambda q: q._with_current_path(effective_path).
_conditional_options(*options),
- effective_path.path, key
+ cache_path.path, key
)
def _retrieve_baked_query(self, session):