diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-09 11:46:44 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-03-09 11:46:44 -0500 |
commit | d5d9a8c24ed178cbc45c7caf8452e0fda5578ea4 (patch) | |
tree | 4354fc624c0988bd8cb84a655065830cbda1242e /lib/sqlalchemy/sql/expression.py | |
parent | 9793bf7fb26af7fced221096d2ca75a37d941001 (diff) | |
download | sqlalchemy-d5d9a8c24ed178cbc45c7caf8452e0fda5578ea4.tar.gz |
- since correlation is now always at least semi-automatic, remove the
ability for correlation to have any effect for a SELECT that's stated
in the FROM.
- add a new exhaustive test suite for correlation to test_compiler
Diffstat (limited to 'lib/sqlalchemy/sql/expression.py')
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 0ebcc1146..41eaace71 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -5258,34 +5258,36 @@ class Select(HasPrefixes, SelectBase): # using a list to maintain ordering froms = [f for f in froms if f not in toremove] - if self._correlate: - froms = [ - f for f in froms if f not in - _cloned_intersection( - _cloned_intersection(froms, existing_froms or ()), - self._correlate - ) - ] - if self._correlate_except: - froms = [ - f for f in froms if f in - _cloned_intersection( - froms, - self._correlate_except - ) - ] - if self._auto_correlate and existing_froms and len(froms) > 1 and not asfrom: - froms = [ - f for f in froms if f not in - _cloned_intersection(froms, existing_froms) - ] - - if not len(froms): - raise exc.InvalidRequestError("Select statement '%s" - "' returned no FROM clauses due to " - "auto-correlation; specify " - "correlate(<tables>) to control " - "correlation manually." % self) + if not asfrom: + if self._correlate: + froms = [ + f for f in froms if f not in + _cloned_intersection( + _cloned_intersection(froms, existing_froms or ()), + self._correlate + ) + ] + if self._correlate_except: + froms = [ + f for f in froms if f in + _cloned_intersection( + froms, + self._correlate_except + ) + ] + + if self._auto_correlate and existing_froms and len(froms) > 1: + froms = [ + f for f in froms if f not in + _cloned_intersection(froms, existing_froms) + ] + + if not len(froms): + raise exc.InvalidRequestError("Select statement '%s" + "' returned no FROM clauses due to " + "auto-correlation; specify " + "correlate(<tables>) to control " + "correlation manually." % self) return froms |