From b7ba3f0d9395236cbf05f830d82f6494163d1dfb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 25 Sep 2018 11:11:41 -0400 Subject: 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 --- test/dialect/postgresql/test_compiler.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') 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)) -- cgit v1.2.1