From: Mike Bayer Date: Fri, 18 May 2007 19:01:47 +0000 (+0000) Subject: - removed "no group by's in a select thats part of a UNION" X-Git-Tag: rel_0_3_8~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9102d678abdaf7e9ab0ce59a913283eb16810b9a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - removed "no group by's in a select thats part of a UNION" restriction [ticket:578] --- diff --git a/CHANGES b/CHANGES index ee08b9f7f1..3dab91e901 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,8 @@ clauses placed in other clauses, i.e. no 'parens' flag) - added 'modifier' keyword, works like func. except does not add parenthesis. e.g. select([modifier.DISTINCT(...)]) etc. + - removed "no group by's in a select thats part of a UNION" + restriction [ticket:578] - orm - "delete-orphan" no longer implies "delete". ongoing effort to separate the behavior of these two operations. diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 69cef08cae..35cd30b304 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -2686,7 +2686,6 @@ class CompoundSelect(_SelectBaseMixin, FromClause): # 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) self.group_by(*kwargs.pop('group_by', [None])) diff --git a/test/sql/select.py b/test/sql/select.py index 395243aeee..281a0f6a38 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -628,6 +628,17 @@ FROM myothertable ORDER BY myid \ LIMIT 5 OFFSET 10" ) + self.runtest( + union( + select([table1.c.myid, table1.c.name, func.max(table1.c.description)], table1.c.name=='name2', group_by=[table1.c.myid, table1.c.name]), + table1.select(table1.c.name=='name1') + ) + , + "SELECT mytable.myid, mytable.name, max(mytable.description) FROM mytable \ +WHERE mytable.name = :mytable_name GROUP BY mytable.myid, mytable.name UNION SELECT mytable.myid, mytable.name, mytable.description \ +FROM mytable WHERE mytable.name = :mytable_name_1" + ) + def testouterjoin(self): # test an outer join. the oracle module should take the ON clause of the join and # move it up to the WHERE clause of its parent select, and append (+) to all right-hand-side columns