diff options
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/orm/query.py | 15 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 6c5e8c81c..b22a10b55 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -98,6 +98,7 @@ class Query(object): _attributes = util.frozendict() _with_options = () _with_hints = () + _enable_single_crit = True def __init__(self, entities, session=None): self.session = session @@ -701,12 +702,17 @@ class Query(object): """ fromclause = self.with_labels().enable_eagerloads(False).\ + _enable_single_crit(False).\ statement.correlate(None) q = self._from_selectable(fromclause) if entities: q._set_entities(entities) return q - + + @_generative() + def _enable_single_crit(self, val): + self._enable_single_crit = val + @_generative() def _from_selectable(self, fromclause): for attr in ('_statement', '_criterion', '_order_by', '_group_by', @@ -1936,7 +1942,8 @@ class Query(object): else: from_obj = context.froms - self._adjust_for_single_inheritance(context) + if self._enable_single_crit: + self._adjust_for_single_inheritance(context) whereclause = context.whereclause @@ -2273,7 +2280,8 @@ class Query(object): # i.e. when each _MappedEntity has its own FROM froms = context.froms - self._adjust_for_single_inheritance(context) + if self._enable_single_crit: + self._adjust_for_single_inheritance(context) if not context.primary_columns: if self._only_load_props: @@ -2405,6 +2413,7 @@ class Query(object): selected from the total results. """ + for entity, (mapper, adapter, s, i, w) in \ self._mapper_adapter_map.iteritems(): single_crit = mapper._single_table_criterion diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index b0a18b7dd..3e6b6a21f 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -765,6 +765,7 @@ class SubqueryLoader(AbstractRelationshipLoader): ("orig_query", SubqueryLoader): orig_query, ('subquery_path', None) : subq_path } + q = q._enable_single_crit(False) # figure out what's being joined. a.k.a. the fun part to_join = [ |