diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-11-09 16:12:30 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-11-09 16:12:30 -0500 |
| commit | b3c3562ecf67ae7c94091287504579fcace6a500 (patch) | |
| tree | a3e6a37d22f9ff239264d0a10ebf41c91358f3ae /test/dialect | |
| parent | ed2c5f9ad1f92010e447797576ab4eef3beee21f (diff) | |
| download | sqlalchemy-b3c3562ecf67ae7c94091287504579fcace6a500.tar.gz | |
Interpret empty LIMIT, expression LIMIT correctly
Fixed issue in MSSQL dialect where an expression-based OFFSET value in a
SELECT would be rejected, even though the dialect can render this
expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct.
Fixes: #4973
Change-Id: I040d34f781791c4ed5a727e1b8fb98c68ddd0622
Diffstat (limited to 'test/dialect')
| -rw-r--r-- | test/dialect/mssql/test_compiler.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py index 6b3244c30..b0f58563a 100644 --- a/test/dialect/mssql/test_compiler.py +++ b/test/dialect/mssql/test_compiler.py @@ -8,6 +8,7 @@ from sqlalchemy import Index from sqlalchemy import insert from sqlalchemy import Integer from sqlalchemy import literal +from sqlalchemy import literal_column from sqlalchemy import MetaData from sqlalchemy import PrimaryKeyConstraint from sqlalchemy import schema @@ -784,6 +785,28 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): eq_(len(c._result_columns), 2) assert t.c.x in set(c._create_result_map()["x"][1]) + def test_simple_limit_expression_offset_using_window(self): + t = table("t", column("x", Integer), column("y", Integer)) + + s = ( + select([t]) + .where(t.c.x == 5) + .order_by(t.c.y) + .limit(10) + .offset(literal_column("20")) + ) + + self.assert_compile( + s, + "SELECT anon_1.x, anon_1.y " + "FROM (SELECT t.x AS x, t.y AS y, " + "ROW_NUMBER() OVER (ORDER BY t.y) AS mssql_rn " + "FROM t " + "WHERE t.x = :x_1) AS anon_1 " + "WHERE mssql_rn > 20 AND mssql_rn <= :param_1 + 20", + checkparams={"param_1": 10, "x_1": 5}, + ) + def test_limit_offset_using_window(self): t = table("t", column("x", Integer), column("y", Integer)) |
