summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/query.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-07-01 20:50:57 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-07-01 20:50:57 -0400
commit87f33448814e2e1dfeff28750e523cd7ec88985d (patch)
treedf1a76d75e7a01eef2f3dff287d466d1baffdc5c /lib/sqlalchemy/orm/query.py
parent25db56bc0c1ee30fc0ad9166ac48de7dc8328762 (diff)
downloadsqlalchemy-87f33448814e2e1dfeff28750e523cd7ec88985d.tar.gz
- Query.join() will check for a call of the
form query.join(target, clause_expression), i.e. missing the tuple, and raise an informative error message that this is the wrong calling form.
Diffstat (limited to 'lib/sqlalchemy/orm/query.py')
-rw-r--r--lib/sqlalchemy/orm/query.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index 6b36b370a..b3588ae59 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1110,7 +1110,15 @@ class Query(object):
if not from_joinpoint:
self._reset_joinpoint()
-
+
+ if len(keys) >= 2 and \
+ isinstance(keys[1], expression.ClauseElement) and \
+ not isinstance(keys[1], expression.FromClause):
+ raise sa_exc.ArgumentError(
+ "You appear to be passing a clause expression as the second "
+ "argument to query.join(). Did you mean to use the form "
+ "query.join((target, onclause))? Note the tuple.")
+
for arg1 in util.to_list(keys):
if isinstance(arg1, tuple):
arg1, arg2 = arg1
@@ -1326,9 +1334,10 @@ class Query(object):
if clause is None:
raise sa_exc.InvalidRequestError(
"Could not find a FROM clause to join from")
-
+
clause = orm_join(clause, right, onclause,
- isouter=outerjoin, join_to_left=join_to_left)
+ isouter=outerjoin, join_to_left=join_to_left)
+
self._from_obj = self._from_obj + (clause,)
def _reset_joinpoint(self):