diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-16 15:33:39 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-16 15:33:39 -0400 |
commit | 81959af6d37be503a13ce9c53317d443e14ae570 (patch) | |
tree | 98cf5d471114a6b14c91e7bd037009e04f604609 /test/sql/test_compiler.py | |
parent | 8414c9f00b9ddf972d6b78c6883c315beaf29822 (diff) | |
download | sqlalchemy-81959af6d37be503a13ce9c53317d443e14ae570.tar.gz |
- more tests, including backend tests
- implement for SQL server, use window functions when simple limit/offset not available
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 917c7d89d..301cf149c 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -167,6 +167,57 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): assert_raises(ValueError, select, offset="foo") assert_raises(ValueError, select, limit="foo") + def test_limit_offset_no_int_coercion_one(self): + exp1 = literal_column("Q") + exp2 = literal_column("Y") + self.assert_compile( + select([1]).limit(exp1).offset(exp2), + "SELECT 1 LIMIT Q OFFSET Y" + ) + + self.assert_compile( + select([1]).limit(bindparam('x')).offset(bindparam('y')), + "SELECT 1 LIMIT :x OFFSET :y" + ) + + def test_limit_offset_no_int_coercion_two(self): + exp1 = literal_column("Q") + exp2 = literal_column("Y") + sel = select([1]).limit(exp1).offset(exp2) + + assert_raises_message( + exc.CompileError, + "This SELECT structure does not use a simple integer " + "value for limit", + getattr, sel, "_limit" + ) + + assert_raises_message( + exc.CompileError, + "This SELECT structure does not use a simple integer " + "value for offset", + getattr, sel, "_offset" + ) + + def test_limit_offset_no_int_coercion_three(self): + exp1 = bindparam("Q") + exp2 = bindparam("Y") + sel = select([1]).limit(exp1).offset(exp2) + + assert_raises_message( + exc.CompileError, + "This SELECT structure does not use a simple integer " + "value for limit", + getattr, sel, "_limit" + ) + + assert_raises_message( + exc.CompileError, + "This SELECT structure does not use a simple integer " + "value for offset", + getattr, sel, "_offset" + ) + def test_limit_offset(self): for lim, offset, exp, params in [ (5, 10, "LIMIT :param_1 OFFSET :param_2", @@ -182,6 +233,8 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): checkparams=params ) + + def test_select_precol_compile_ordering(self): s1 = select([column('x')]).select_from('a').limit(5).as_scalar() s2 = select([s1]).limit(10) |