summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-02-16 19:29:00 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-02-16 19:29:00 -0500
commit35cba3c84ab9c36663e57049e56e59cace5aa2f7 (patch)
treed3ff7633a67526fa28c35715b599bb8129704c50 /lib/sqlalchemy
parent9b86654981ce0c172ad09401ad41e15d5b8d0487 (diff)
downloadsqlalchemy-35cba3c84ab9c36663e57049e56e59cace5aa2f7.tar.gz
break up _join_left_to_right to call upon _prepare_right_side and _join_to_left.
this separates the handling of each side totally making it easier to see what's going on.
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/query.py41
1 files changed, 28 insertions, 13 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 6321715f4..e012cd9b0 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1692,7 +1692,29 @@ class Query(object):
"are the same entity" %
(left, right))
- left_mapper, left_selectable, left_is_aliased = _entity_info(left)
+ right, right_is_aliased, onclause = self._prepare_right_side(
+ right, onclause,
+ outerjoin, create_aliases,
+ prop)
+
+ # if joining on a MapperProperty path,
+ # track the path to prevent redundant joins
+ if not create_aliases and prop:
+ self._update_joinpoint({
+ '_joinpoint_entity':right,
+ 'prev':((left, right, prop.key), self._joinpoint)
+ })
+ else:
+ self._joinpoint = {
+ '_joinpoint_entity':right
+ }
+
+ self._join_to_left(left, right,
+ right_is_aliased,
+ onclause, outerjoin)
+
+ def _prepare_right_side(self, right, onclause, outerjoin,
+ create_aliases, prop):
right_mapper, right_selectable, right_is_aliased = _entity_info(right)
if right_mapper:
@@ -1737,18 +1759,6 @@ class Query(object):
right = aliased(right)
need_adapter = True
- # if joining on a MapperProperty path,
- # track the path to prevent redundant joins
- if not create_aliases and prop:
- self._update_joinpoint({
- '_joinpoint_entity':right,
- 'prev':((left, right, prop.key), self._joinpoint)
- })
- else:
- self._joinpoint = {
- '_joinpoint_entity':right
- }
-
# if an alias() of the right side was generated here,
# apply an adapter to all subsequent filter() calls
# until reset_joinpoint() is called.
@@ -1776,6 +1786,11 @@ class Query(object):
)
)
+ return right, right_is_aliased, onclause
+
+ def _join_to_left(self, left, right, right_is_aliased, onclause, outerjoin):
+ left_mapper, left_selectable, left_is_aliased = _entity_info(left)
+
# this is an overly broad assumption here, but there's a
# very wide variety of situations where we rely upon orm.join's
# adaption to glue clauses together, with joined-table inheritance's