diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-10-25 18:04:59 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-10-25 18:04:59 +0000 |
| commit | e82eebb368718ba1fe24853373399f0fbd2c17e4 (patch) | |
| tree | d1664d6cce3b78bdbce4c7fd63fd67920a7cda14 /lib/sqlalchemy | |
| parent | af1bb6b95553db49af2dc2aa73b75a24b752c6bc (diff) | |
| download | sqlalchemy-e82eebb368718ba1fe24853373399f0fbd2c17e4.tar.gz | |
- When using Query.join() with an explicit clause for the
ON clause, the clause will be aliased in terms of the left
side of the join, allowing scenarios like query(Source).
from_self().join((Dest, Source.id==Dest.source_id)) to work
properly.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/util.py | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index b53256a24..93699b79a 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -885,8 +885,12 @@ class Query(object): onclause = right_adapter.traverse(onclause) if prop: + # MapperProperty based onclause onclause = prop - + else: + # ClauseElement based onclause + onclause = self._adapt_clause(onclause, False, True) + clause = orm_join(clause, right_entity, onclause, isouter=outerjoin) if alias_criterion: self._filter_aliases = right_adapter diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index 4172b99cc..264a4d212 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -379,7 +379,7 @@ class _ORMJoin(expression.Join): else: onclause = pj self._target_adapter = target_adapter - + expression.Join.__init__(self, left, right, onclause, isouter) def join(self, right, onclause=None, isouter=False): |
