summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--lib/sqlalchemy/sql.py1
-rw-r--r--test/sql/select.py11
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index ee08b9f7f..3dab91e90 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.<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.
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 69cef08ca..35cd30b30 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 395243aee..281a0f6a3 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