summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-09-25 11:11:41 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-09-25 11:14:32 -0400
commitb7ba3f0d9395236cbf05f830d82f6494163d1dfb (patch)
treed39eb1feca35b5deb96749f18096935d57bf7967 /test/dialect/postgresql/test_compiler.py
parentfb991a4474fa0d4df69af10a808fe234016c6a52 (diff)
downloadsqlalchemy-b7ba3f0d9395236cbf05f830d82f6494163d1dfb.tar.gz
Accept multiple expressions for aggregate_order_by order_by
Added support for the :class:`.aggregate_order_by` function to receive multiple ORDER BY elements, previously only a single element was accepted. Fixes: #4337 Change-Id: I411ac31697a0d65b568ad65ce5b5181717afbd65
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 6133ab482..3ebc4a1ab 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -1100,6 +1100,31 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
"AS string_agg_1 FROM table1"
)
+ def test_aggregate_order_by_multi_col(self):
+ m = MetaData()
+ table = Table('table1', m, Column('a', Integer), Column('b', Integer))
+ expr = func.string_agg(
+ table.c.a,
+ aggregate_order_by(
+ literal_column("','"),
+ table.c.a, table.c.b.desc())
+ )
+ stmt = select([expr])
+
+ self.assert_compile(
+ stmt,
+ "SELECT string_agg(table1.a, "
+ "',' ORDER BY table1.a, table1.b DESC) "
+ "AS string_agg_1 FROM table1"
+ )
+
+ def test_aggregate_orcer_by_no_arg(self):
+ assert_raises_message(
+ TypeError,
+ "at least one ORDER BY element is required",
+ aggregate_order_by, literal_column("','")
+ )
+
def test_pg_array_agg_implicit_pg_array(self):
expr = pg_array_agg(column('data', Integer))