From 2bc8c92279a165563b7ebcf82c96cd3cd7ede2a2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 15 Apr 2015 17:30:23 -0400 Subject: - Identified an inconsistency when handling :meth:`.Query.join` to the same target more than once; it implicitly dedupes only in the case of a relationship join, and due to :ticket:`3233`, in 1.0 a join to the same table twice behaves differently than 0.9 in that it no longer erroneously aliases. To help document this change, the verbiage regarding :ticket:`3233` in the migration notes has been generalized, and a warning has been added when :meth:`.Query.join` is called against the same target relationship more than once. fixes #3367 --- lib/sqlalchemy/orm/query.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index d02c071db..2bd68899b 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1815,7 +1815,8 @@ class Query(object): # convert to a tuple. keys = (keys,) - for arg1 in util.to_list(keys): + keylist = util.to_list(keys) + for idx, arg1 in enumerate(keylist): if isinstance(arg1, tuple): # "tuple" form of join, multiple # tuples are accepted as well. The simpler @@ -1894,6 +1895,11 @@ class Query(object): jp = self._joinpoint[edge].copy() jp['prev'] = (edge, self._joinpoint) self._update_joinpoint(jp) + + if idx == len(keylist) - 1: + util.warn( + "Pathed join target %s has already " + "been joined to; skipping" % prop) continue elif onclause is not None and right_entity is None: -- cgit v1.2.1