diff options
Diffstat (limited to 'test/sql/test_compiler.py')
| -rw-r--r-- | test/sql/test_compiler.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index bfb282050..ce3e9003b 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1,5 +1,5 @@ from test.lib.testing import eq_, assert_raises, assert_raises_message -import datetime, re, operator +import datetime, re, operator, decimal from sqlalchemy import * from sqlalchemy import exc, sql, util from sqlalchemy.sql import table, column, label, compiler @@ -106,6 +106,24 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): assert_raises(exc.ArgumentError, select, table1) assert_raises(exc.ArgumentError, select, table1.c.myid) + def test_int_limit_offset_coercion(self): + for given, exp in [ + ("5", 5), + (5, 5), + (5.2, 5), + (decimal.Decimal("5"), 5), + (None, None), + ]: + eq_(select().limit(given)._limit, exp) + eq_(select().offset(given)._offset, exp) + eq_(select(limit=given)._limit, exp) + eq_(select(offset=given)._offset, exp) + + assert_raises(ValueError, select().limit, "foo") + assert_raises(ValueError, select().offset, "foo") + assert_raises(ValueError, select, offset="foo") + assert_raises(ValueError, select, limit="foo") + def test_from_subquery(self): """tests placing select statements in the column clause of another select, for the purposes of selecting from the exported columns of that select.""" |
