summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/expression.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-19 15:30:48 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-19 15:30:48 -0400
commitc6fbff56a38e23bfde3bd8d3982c4eb1e944be03 (patch)
tree5ccd7fcf0a0fe9be51aebbc5abde8feab87084fe /lib/sqlalchemy/sql/expression.py
parent5f15e5569c89cc39918752d54520abb89b760a18 (diff)
downloadsqlalchemy-c6fbff56a38e23bfde3bd8d3982c4eb1e944be03.tar.gz
- join() will now simulate a NATURAL JOIN by default. Meaning,
if the left side is a join, it will attempt to join the right side to the rightmost side of the left first, and not raise any exceptions about ambiguous join conditions if successful even if there are further join targets across the rest of the left. [ticket:1714]
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r--lib/sqlalchemy/sql/expression.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 9bc127291..1e02ba96a 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2853,11 +2853,15 @@ class Join(FromClause):
def get_children(self, **kwargs):
return self.left, self.right, self.onclause
- def _match_primaries(self, primary, secondary):
+ def _match_primaries(self, left, right):
global sql_util
if not sql_util:
from sqlalchemy.sql import util as sql_util
- return sql_util.join_condition(primary, secondary)
+ if isinstance(left, Join):
+ left_right = left.right
+ else:
+ left_right = None
+ return sql_util.join_condition(left, right, a_subset=left_right)
def select(self, whereclause=None, fold_equivalents=False, **kwargs):
"""Create a :class:`Select` from this :class:`Join`.