summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-09-13 22:55:54 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-09-13 22:55:54 -0400
commit03523970d993b06ff8bed86e2af3ea153cd6112b (patch)
treeff3f50c5c3c3b6698599155fc4e9786c1f20d07d /lib/sqlalchemy
parent2ed6f06329a7bb2f780aebc467a72321dfb5c204 (diff)
downloadsqlalchemy-03523970d993b06ff8bed86e2af3ea153cd6112b.tar.gz
- Fixed bug that would prevent "subqueryload" from
working correctly with single table inheritance for a relationship from a subclass - the "where type in (x, y, z)" only gets placed on the inside, instead of repeatedly. - When using from_self() with single table inheritance, the "where type in (x, y, z)" is placed on the outside of the query only, instead of repeatedly. May make some more adjustments to this.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py15
-rw-r--r--lib/sqlalchemy/orm/strategies.py1
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 = [