summaryrefslogtreecommitdiff
path: root/test/sql/select.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-12-06 00:14:50 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-12-06 00:14:50 +0000
commit6eca02a31f9fdbc7d039a89f6f8ea212fe5121d9 (patch)
tree3c57fe4a61566acfe9e2eb22a8cd0d1a54ca8771 /test/sql/select.py
parentecc6c1da2adddddc09d99be582595cd41f98ac16 (diff)
downloadsqlalchemy-6eca02a31f9fdbc7d039a89f6f8ea212fe5121d9.tar.gz
- union() and union_all() will not whack
any order_by() that has been applied to the select()s inside. If you union() a select() with order_by() (presumably to support LIMIT/OFFSET), you should also call self_group() on it to apply parenthesis.
Diffstat (limited to 'test/sql/select.py')
-rw-r--r--test/sql/select.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py
index 91585e37e..352eed42c 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -982,6 +982,16 @@ UNION SELECT mytable.myid FROM mytable"
s = union(s, s)
self.assert_compile(s, "SELECT foo, bar UNION SELECT foo, bar UNION (SELECT foo, bar UNION SELECT foo, bar)")
+ s = select([column('foo'), column('bar')])
+ # ORDER BY's even though not supported by all DB's, are rendered if requested
+ self.assert_compile(union(s.order_by("foo"), s.order_by("bar")),
+ "SELECT foo, bar ORDER BY foo UNION SELECT foo, bar ORDER BY bar"
+ )
+ # self_group() is honored
+ self.assert_compile(union(s.order_by("foo").self_group(), s.order_by("bar").limit(10).self_group()),
+ "(SELECT foo, bar ORDER BY foo) UNION (SELECT foo, bar ORDER BY bar LIMIT 10)"
+ )
+
@testing.uses_deprecated()
def test_binds(self):