summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnts Aasma <ants.aasma@gmail.com>2007-06-26 18:00:57 +0000
committerAnts Aasma <ants.aasma@gmail.com>2007-06-26 18:00:57 +0000
commit51c0d90c8d3dff721329d5ef0eb896227aff3c99 (patch)
treeb412a073db99e06374f458db8a78203e87f55956 /test
parentb191254d8aceca10b40dd5957f3ddf9147a4c534 (diff)
downloadsqlalchemy-51c0d90c8d3dff721329d5ef0eb896227aff3c99.tar.gz
add missing grouping for compound selects. fixes ticket #623
Diffstat (limited to 'test')
-rw-r--r--test/sql/query.py23
-rw-r--r--test/sql/select.py27
2 files changed, 50 insertions, 0 deletions
diff --git a/test/sql/query.py b/test/sql/query.py
index f7c38eb87..632246fad 100644
--- a/test/sql/query.py
+++ b/test/sql/query.py
@@ -624,6 +624,29 @@ class CompoundTest(PersistTest):
assert e.execute().fetchall() == [('aaa', 'aaa'), ('aaa', 'ccc'), ('bbb', 'aaa'), ('bbb', 'bbb'), ('ccc', 'bbb'), ('ccc', 'ccc')]
assert e.alias('bar').select().execute().fetchall() == [('aaa', 'aaa'), ('aaa', 'ccc'), ('bbb', 'aaa'), ('bbb', 'bbb'), ('ccc', 'bbb'), ('ccc', 'ccc')]
+ @testbase.unsupported('sqlite', 'mysql', 'oracle')
+ def test_except_style3(self):
+ # aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc
+ e = except_(
+ select([t1.c.col3]), # aaa, bbb, ccc
+ except_(
+ select([t2.c.col3]), # aaa, bbb, ccc
+ select([t3.c.col3], t3.c.col3 == 'ccc'), #ccc
+ )
+ )
+ self.assertEquals(e.execute().fetchall(), [('ccc',)])
+
+ @testbase.unsupported('sqlite', 'mysql', 'oracle')
+ def test_union_union_all(self):
+ e = union_all(
+ select([t1.c.col3]),
+ union(
+ select([t1.c.col3]),
+ select([t1.c.col3]),
+ )
+ )
+ self.assertEquals(e.execute().fetchall(), [('aaa',),('bbb',),('ccc',),('aaa',),('bbb',),('ccc',)])
+
@testbase.unsupported('mysql')
def test_composite(self):
u = intersect(
diff --git a/test/sql/select.py b/test/sql/select.py
index 10fa631f0..4d3eb4ad7 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -663,6 +663,33 @@ FROM myothertable ORDER BY myid \
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 test_compound_select_grouping(self):
+ self.runtest(
+ union_all(
+ select([table1.c.myid]),
+ union(
+ select([table2.c.otherid]),
+ select([table3.c.userid]),
+ )
+ )
+ ,
+ "SELECT mytable.myid FROM mytable UNION ALL (SELECT myothertable.otherid FROM myothertable UNION \
+SELECT thirdtable.userid FROM thirdtable)"
+ )
+ # This doesn't need grouping, so don't group to not give sqlite unnecessarily hard time
+ self.runtest(
+ union(
+ except_(
+ select([table2.c.otherid]),
+ select([table3.c.userid]),
+ ),
+ select([table1.c.myid])
+ )
+ ,
+ "SELECT myothertable.otherid FROM myothertable EXCEPT SELECT thirdtable.userid FROM thirdtable \
+UNION SELECT mytable.myid FROM mytable"
+ )
def testouterjoin(self):
# test an outer join. the oracle module should take the ON clause of the join and