diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-29 22:13:58 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-29 22:13:58 +0000 |
| commit | 13d989b2d0064b00c4b231c9d90bf4a2a6dfd56a (patch) | |
| tree | 348f031172cb1de8ccc9887badd2a1b8fd2e1725 /lib/sqlalchemy/sql.py | |
| parent | 6bba73a9f3bd10e23ceaf14349ef10978b7eb5df (diff) | |
| download | sqlalchemy-13d989b2d0064b00c4b231c9d90bf4a2a6dfd56a.tar.gz | |
- sending a selectable to an IN no longer creates a "union" out of multiple
selects; only one selectable to an IN is allowed now (make a union yourself
if union is needed; explicit better than implicit, dont guess, etc.)
Diffstat (limited to 'lib/sqlalchemy/sql.py')
| -rw-r--r-- | lib/sqlalchemy/sql.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 17c0a25f7..acdba2c70 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -545,10 +545,12 @@ class _CompareMixin(object): elif _is_literal(other[0]): return self._compare('IN', ClauseList(parens=True, *[self._bind_param(o) for o in other]), negate='NOT IN') else: - # assume *other is a list of selects. - # so put them in a UNION. if theres only one, you just get one SELECT - # statement out of it. - return self._compare('IN', union(parens=True, *other), negate='NOT IN') + # assume *other is a single select. + # originally, this assumed possibly multiple selects and created a UNION, + # but we are now forcing explictness if a UNION is desired. + if len(other) > 1: + raise exceptions.InvalidRequestException("in() function accepts only multiple literal values, or a single selectable as an argument") + return self._compare('IN', other[0], negate='NOT IN') def startswith(self, other): return self._compare('LIKE', other + "%") def endswith(self, other): @@ -1366,6 +1368,7 @@ class CompoundSelect(_SelectBaseMixin, FromClause): self.selects = selects + # some DBs do not like ORDER BY in the inner queries of a UNION, etc. for s in selects: s.group_by(None) s.order_by(None) |
