diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-31 13:29:10 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-31 13:29:10 -0400 |
commit | dedc85ba9d8e3292311c4593d2252a44556cd7fe (patch) | |
tree | f75e063b157f4ea97e83535b3e57ae2b73985c09 /lib/sqlalchemy/orm/util.py | |
parent | 4318edf9bb3e08a9e59a2ff1270d69fc21fd0c93 (diff) | |
download | sqlalchemy-dedc85ba9d8e3292311c4593d2252a44556cd7fe.tar.gz |
- further fixes for #3347; track the mappers we're joining
between fully and match on those, rather than trying to
compare selectables; fixes #3347
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r-- | lib/sqlalchemy/orm/util.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index ad071376d..b3f3bc5fa 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -776,7 +776,10 @@ class _ORMJoin(expression.Join): __visit_name__ = expression.Join.__visit_name__ - def __init__(self, left, right, onclause=None, isouter=False): + def __init__( + self, + left, right, onclause=None, isouter=False, + _left_memo=None, _right_memo=None): left_info = inspection.inspect(left) left_orm_info = getattr(left, '_joined_from_info', left_info) @@ -786,6 +789,9 @@ class _ORMJoin(expression.Join): self._joined_from_info = right_info + self._left_memo = _left_memo + self._right_memo = _right_memo + if isinstance(onclause, util.string_types): onclause = getattr(left_orm_info.entity, onclause) @@ -837,6 +843,28 @@ class _ORMJoin(expression.Join): single_crit = right_info._adapter.traverse(single_crit) self.onclause = self.onclause & single_crit + def _splice_into_center(self, other): + """Splice a join into the center. + + Given join(a, b) and join(b, c), return join(a, b).join(c) + + """ + assert self.right is other.left + + left = _ORMJoin( + self.left, other.left, + self.onclause, isouter=self.isouter, + _left_memo=self._left_memo, + _right_memo=other._left_memo + ) + + return _ORMJoin( + left, + other.right, + other.onclause, isouter=other.isouter, + _right_memo=other._right_memo + ) + def join(self, right, onclause=None, isouter=False, join_to_left=None): return _ORMJoin(self, right, onclause, isouter) |