summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 20:57:27 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-12-03 20:57:27 -0500
commit252acd50d8ae0fe58d61cf7f053dfe1fe4206de4 (patch)
tree6d2f1c17aeb3de4af524814c93d1950e68e27f2d /lib/sqlalchemy
parent7c993de6cee97dc8c2c9ac0a988e410ccd7fa97c (diff)
downloadsqlalchemy-252acd50d8ae0fe58d61cf7f053dfe1fe4206de4.tar.gz
- [bug] Calls to query.join() to a single-table
inheritance subclass are now tracked, and are used to eliminate the additional WHERE.. IN criterion normally tacked on with single table inheritance, since the join should accommodate it. This allows OUTER JOIN to a single table subclass to produce the correct results, and overall will produce fewer WHERE criterion when dealing with single table inheritance joins. [ticket:2328]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 9c7ef7b8e..60176dfe3 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -89,6 +89,7 @@ class Query(object):
_only_load_props = None
_refresh_state = None
_from_obj = ()
+ _join_entities = ()
_select_from_entity = None
_filter_aliases = None
_from_obj_alias = None
@@ -1641,6 +1642,9 @@ class Query(object):
left_mapper, left_selectable, left_is_aliased = _entity_info(left)
right_mapper, right_selectable, right_is_aliased = _entity_info(right)
+ if right_mapper:
+ self._join_entities += (right, )
+
if right_mapper and prop and \
not right_mapper.common_parent(prop.mapper):
raise sa_exc.InvalidRequestError(
@@ -2818,9 +2822,10 @@ class Query(object):
selected from the total results.
"""
-
for entity, (mapper, adapter, s, i, w) in \
self._mapper_adapter_map.iteritems():
+ if entity in self._join_entities:
+ continue
single_crit = mapper._single_table_criterion
if single_crit is not None:
if adapter: