]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- removed "no group by's in a select thats part of a UNION"
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 May 2007 19:01:47 +0000 (19:01 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 18 May 2007 19:01:47 +0000 (19:01 +0000)
restriction [ticket:578]

CHANGES
lib/sqlalchemy/sql.py
test/sql/select.py

diff --git a/CHANGES b/CHANGES
index ee08b9f7f160403a26a49f881a979f063ba83ef3..3dab91e901f223692df3301001607a59cd8b4e8f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,8 @@
       clauses placed in other clauses, i.e. no 'parens' flag)
     - added 'modifier' keyword, works like func.<foo> 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.
index 69cef08cae8f00589a1a0664505af4ed2a73b123..35cd30b30415d807d170c1c5358724240c3fe2d7 100644 (file)
@@ -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]))
index 395243aeee23e158aed79989f7c7da3418c532f9..281a0f6a381f39a991c4a5ffe86d2683201b5c3c 100644 (file)
@@ -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