summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-08-06 15:03:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-08-06 15:03:33 -0400
commit5751eb17f134715d80534531898c091f23cd216b (patch)
treefe6ee564d2e6fb8218648ac1266b92c31a805ff1 /test/dialect
parentb9a4eacfa3675f2eb9a141499d83cf532c263e01 (diff)
downloadsqlalchemy-5751eb17f134715d80534531898c091f23cd216b.tar.gz
- Query will convert an OFFSET of zero when
slicing into None, so that needless OFFSET clauses are not invoked. - mssql: "0" is accepted as an argument for limit() which will produce "TOP 0". [ticket:2222] - add tests to default compiler test for LIMIT/OFFSET generation
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/test_mssql.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py
index ef5d26195..4cce395b8 100644
--- a/test/dialect/test_mssql.py
+++ b/test/dialect/test_mssql.py
@@ -287,7 +287,18 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
self.assert_compile(
s,
"SELECT TOP 10 t.x, t.y FROM t WHERE t.x = :x_1 ORDER BY t.y",
- {u'x_1': 5}
+ checkparams={u'x_1': 5}
+ )
+
+ def test_limit_zero_using_top(self):
+ t = table('t', column('x', Integer), column('y', Integer))
+
+ s = select([t]).where(t.c.x==5).order_by(t.c.y).limit(0)
+
+ self.assert_compile(
+ s,
+ "SELECT TOP 0 t.x, t.y FROM t WHERE t.x = :x_1 ORDER BY t.y",
+ checkparams={u'x_1': 5}
)
def test_offset_using_window(self):
@@ -301,7 +312,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
"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 > :mssql_rn_1",
- {u'mssql_rn_1': 20, u'x_1': 5}
+ checkparams={u'mssql_rn_1': 20, u'x_1': 5}
)
def test_limit_offset_using_window(self):
@@ -317,7 +328,21 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
"FROM t "
"WHERE t.x = :x_1) AS anon_1 "
"WHERE mssql_rn > :mssql_rn_1 AND mssql_rn <= :mssql_rn_2",
- {u'mssql_rn_1': 20, u'mssql_rn_2': 30, u'x_1': 5}
+ checkparams={u'mssql_rn_1': 20, u'mssql_rn_2': 30, u'x_1': 5}
+ )
+
+ def test_limit_zero_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(0).offset(0)
+
+ # render the LIMIT of zero, but not the OFFSET
+ # of zero, so produces TOP 0
+ self.assert_compile(
+ s,
+ "SELECT TOP 0 t.x, t.y FROM t "
+ "WHERE t.x = :x_1 ORDER BY t.y",
+ checkparams={u'x_1': 5}
)