diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-25 09:41:18 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-25 09:42:25 -0400 |
commit | 3a5bbe4cbe12d180fba2b942d0467b46be705bea (patch) | |
tree | 7613927bb275e4b53712cb28c15a1b3f2abe50bd /test/sql/test_compiler.py | |
parent | e33cff44b5822a22c540d316151699203a1fff52 (diff) | |
download | sqlalchemy-3a5bbe4cbe12d180fba2b942d0467b46be705bea.tar.gz |
Allow for multiple FOLLOWING/PRECEDING in a window range
Altered the range specification for window functions to allow
for two of the same PRECEDING or FOLLOWING keywords in a range
by allowing for the left side of the range to be positive
and for the right to be negative, e.g. (1, 3) is
"1 FOLLOWING AND 3 FOLLOWING".
Change-Id: I7d3a6c641151bb49219104968d18dac2266f3db8
Fixes: #4053
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 05893d748..053619f46 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -2426,31 +2426,37 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): "(ORDER BY mytable.myid RANGE BETWEEN " ":param_1 PRECEDING AND :param_2 FOLLOWING)" " AS anon_1 FROM mytable", - {'param_1': 5, 'param_2': 10} + checkparams={'param_1': 5, 'param_2': 10} ) - def test_over_invalid_framespecs(self): - assert_raises_message( - exc.ArgumentError, - "Preceding value must be a negative integer, zero, or None", - func.row_number().over, range_=(5, 10) + self.assert_compile( + select([func.row_number().over(order_by=expr, range_=(1, 10))]), + "SELECT row_number() OVER " + "(ORDER BY mytable.myid RANGE BETWEEN " + ":param_1 FOLLOWING AND :param_2 FOLLOWING)" + " AS anon_1 FROM mytable", + checkparams={'param_1': 1, 'param_2': 10} ) - assert_raises_message( - exc.ArgumentError, - "Following value must be a positive integer, zero, or None", - func.row_number().over, range_=(-5, -8) + self.assert_compile( + select([func.row_number().over(order_by=expr, range_=(-10, -1))]), + "SELECT row_number() OVER " + "(ORDER BY mytable.myid RANGE BETWEEN " + ":param_1 PRECEDING AND :param_2 PRECEDING)" + " AS anon_1 FROM mytable", + checkparams={'param_1': 10, 'param_2': 1} ) + def test_over_invalid_framespecs(self): assert_raises_message( exc.ArgumentError, - "Integer or None expected for preceding value", + "Integer or None expected for range value", func.row_number().over, range_=("foo", 8) ) assert_raises_message( exc.ArgumentError, - "Integer or None expected for following value", + "Integer or None expected for range value", func.row_number().over, range_=(-5, "foo") ) |