diff options
author | Spitcyn <a.ch.clr@gmail.com> | 2017-09-12 10:21:57 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-13 15:18:37 -0400 |
commit | 509d19e6fd38b8e9fec1c588ec958ad1246414a1 (patch) | |
tree | 8a823c6270c5e4b374b54fb87b013846bff7ada3 /test/sql/test_functions.py | |
parent | 31f80b9eaeb3c3435b7f6679b41e434478b1d11c (diff) | |
download | sqlalchemy-review/mike_bayer/pr_github_383.tar.gz |
Implement placeholders for CUBE, ROLLUP, GROUPING SETSreview/mike_bayer/pr_github_383
Fixes: #3429
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I870ee7dc801d553c5309c291402ec468b671e9a9
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/383
Diffstat (limited to 'test/sql/test_functions.py')
-rw-r--r-- | test/sql/test_functions.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 272bd876e..a7dfd2beb 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -86,6 +86,42 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ]: self.assert_compile(func.random(), ret, dialect=dialect) + def test_cube_operators(self): + + t = table('t', column('value'), + column('x'), column('y'), column('z'), column('q')) + + stmt = select([func.sum(t.c.value)]) + + self.assert_compile( + stmt.group_by(func.cube(t.c.x, t.c.y)), + "SELECT sum(t.value) AS sum_1 FROM t GROUP BY CUBE(t.x, t.y)" + ) + + self.assert_compile( + stmt.group_by(func.rollup(t.c.x, t.c.y)), + "SELECT sum(t.value) AS sum_1 FROM t GROUP BY ROLLUP(t.x, t.y)" + ) + + self.assert_compile( + stmt.group_by( + func.grouping_sets(t.c.x, t.c.y) + ), + "SELECT sum(t.value) AS sum_1 FROM t " + "GROUP BY GROUPING SETS(t.x, t.y)" + ) + + self.assert_compile( + stmt.group_by( + func.grouping_sets( + sql.tuple_(t.c.x, t.c.y), + sql.tuple_(t.c.z, t.c.q), + ) + ), + "SELECT sum(t.value) AS sum_1 FROM t GROUP BY " + "GROUPING SETS((t.x, t.y), (t.z, t.q))" + ) + def test_generic_annotation(self): fn = func.coalesce('x', 'y')._annotate({"foo": "bar"}) self.assert_compile( |