summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
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/orm/util.py
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/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 9a397ccf3..4267b79fb 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -1043,7 +1043,13 @@ def was_deleted(object):
state = attributes.instance_state(object)
return state.was_deleted
+
def _entity_corresponds_to(given, entity):
+ """determine if 'given' corresponds to 'entity', in terms
+ of an entity passed to Query that would match the same entity
+ being referred to elsewhere in the query.
+
+ """
if entity.is_aliased_class:
if given.is_aliased_class:
if entity._base_alias is given._base_alias:
@@ -1057,6 +1063,21 @@ def _entity_corresponds_to(given, entity):
return entity.common_parent(given)
+
+def _entity_isa(given, mapper):
+ """determine if 'given' "is a" mapper, in terms of the given
+ would load rows of type 'mapper'.
+
+ """
+ if given.is_aliased_class:
+ return mapper in given.with_polymorphic_mappers or \
+ given.mapper.isa(mapper)
+ elif given.with_polymorphic_mappers:
+ return mapper in given.with_polymorphic_mappers
+ else:
+ return given.isa(mapper)
+
+
def randomize_unitofwork():
"""Use random-ordering sets within the unit of work in order
to detect unit of work sorting issues.