diff options
-rw-r--r-- | lib/sqlalchemy/dialects/sybase/base.py | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/test/requires.py | 30 | ||||
-rw-r--r-- | test/sql/test_query.py | 56 | ||||
-rw-r--r-- | test/sql/test_select.py | 6 |
4 files changed, 58 insertions, 37 deletions
diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py index c0f0879fc..e182cc9e7 100644 --- a/lib/sqlalchemy/dialects/sybase/base.py +++ b/lib/sqlalchemy/dialects/sybase/base.py @@ -263,9 +263,6 @@ class SybaseSQLCompiler(compiler.SQLCompiler): 'milliseconds': 'millisecond' }) - def visit_mod(self, binary, **kw): - return "MOD(%s, %s)" % (self.process(binary.left), self.process(binary.right)) - def get_select_precolumns(self, select): s = select._distinct and "DISTINCT " or "" if select._limit: diff --git a/lib/sqlalchemy/test/requires.py b/lib/sqlalchemy/test/requires.py index 6cfab18ce..c4c745c54 100644 --- a/lib/sqlalchemy/test/requires.py +++ b/lib/sqlalchemy/test/requires.py @@ -10,7 +10,8 @@ from testing import \ _chain_decorators_on, \ exclude, \ emits_warning_on,\ - skip_if + skip_if,\ + fails_on import testing import sys @@ -48,6 +49,8 @@ def boolean_col_expressions(fn): no_support('firebird', 'not supported by database'), no_support('oracle', 'not supported by database'), no_support('mssql', 'not supported by database'), + no_support('sybase', 'not supported by database'), + no_support('maxdb', 'FIXME: verify not supported by database'), ) def identity(fn): @@ -153,6 +156,31 @@ def subqueries(fn): exclude('mysql', '<', (4, 1, 1), 'no subquery support'), ) +def intersect(fn): + """Target database must support INTERSECT or equivlaent.""" + return _chain_decorators_on( + fn, + fails_on('firebird', 'no support for INTERSECT'), + fails_on('mysql', 'no support for INTERSECT'), + fails_on('sybase', 'no support for INTERSECT'), + ) + +def except_(fn): + """Target database must support EXCEPT or equivlaent (i.e. MINUS).""" + return _chain_decorators_on( + fn, + fails_on('firebird', 'no support for EXCEPT'), + fails_on('mysql', 'no support for EXCEPT'), + fails_on('sybase', 'no support for EXCEPT'), + ) + +def offset(fn): + """Target database must support some method of adding OFFSET or equivalent to a result set.""" + return _chain_decorators_on( + fn, + fails_on('sybase', 'no support for OFFSET or equivalent'), + ) + def returning(fn): return _chain_decorators_on( fn, diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 8664ba6dc..3c9d5f0a7 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -810,14 +810,14 @@ class QueryTest(TestBase): assert len(r) == 3 - @testing.emits_warning('.*empty sequence.*') - @testing.fails_on('firebird', 'FIXME: unknown') - @testing.fails_on('maxdb', 'FIXME: unknown') - @testing.fails_on('oracle', 'FIXME: unknown') - @testing.fails_on('mssql', 'FIXME: unknown') + @testing.requires.boolean_col_expressions def test_in_filtering_advanced(self): - """test the behavior of the in_() function when comparing against an empty collection.""" + """test the behavior of the in_() function when + comparing against an empty collection, specifically + that a proper boolean value is generated. + + """ users.insert().execute(user_id = 7, user_name = 'jack') users.insert().execute(user_id = 8, user_name = 'fred') @@ -970,6 +970,7 @@ class LimitTest(TestBase): r = users.select(limit=3, order_by=[users.c.user_id]).execute().fetchall() self.assert_(r == [(1, 'john'), (2, 'jack'), (3, 'ed')], repr(r)) + @testing.requires.offset @testing.fails_on('maxdb', 'FIXME: unknown') def test_select_limit_offset(self): """Test the interaction between limit and offset""" @@ -986,6 +987,7 @@ class LimitTest(TestBase): self.assert_(len(r) == 3, repr(r)) self.assert_(r[0] != r[1] and r[1] != r[2], repr(r)) + @testing.requires.offset @testing.fails_on('mssql', 'FIXME: unknown') def test_select_distinct_offset(self): """Test the interaction between distinct and offset""" @@ -994,6 +996,7 @@ class LimitTest(TestBase): self.assert_(len(r) == 4, repr(r)) self.assert_(r[0] != r[1] and r[1] != r[2] and r[2] != [3], repr(r)) + @testing.requires.offset def test_select_distinct_limit_offset(self): """Test the interaction between limit and limit/offset""" @@ -1144,9 +1147,7 @@ class CompoundTest(TestBase): found2 = self._fetchall_sorted(e.alias('foo').select().execute()) eq_(found2, wanted) - @testing.crashes('firebird', 'Does not support intersect') - @testing.crashes('sybase', 'FIXME: unknown, verify not fails_on') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.intersect def test_intersect(self): i = intersect( select([t2.c.col3, t2.c.col4]), @@ -1161,9 +1162,7 @@ class CompoundTest(TestBase): found2 = self._fetchall_sorted(i.alias('bar').select().execute()) eq_(found2, wanted) - @testing.crashes('firebird', 'Does not support except') - @testing.crashes('sybase', 'FIXME: unknown, verify not fails_on') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.except_ @testing.fails_on('sqlite', "Can't handle this style of nesting") def test_except_style1(self): e = except_(union( @@ -1178,9 +1177,7 @@ class CompoundTest(TestBase): found = self._fetchall_sorted(e.alias().select().execute()) eq_(found, wanted) - @testing.crashes('firebird', 'Does not support except') - @testing.crashes('sybase', 'FIXME: unknown, verify not fails_on') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.except_ def test_except_style2(self): # same as style1, but add alias().select() to the except_(). # sqlite can handle it now. @@ -1200,10 +1197,8 @@ class CompoundTest(TestBase): found2 = self._fetchall_sorted(e.alias().select().execute()) eq_(found2, wanted) - @testing.crashes('firebird', 'Does not support except') - @testing.crashes('sybase', 'FIXME: unknown, verify not fails_on') - @testing.fails_on('mysql', 'FIXME: unknown') @testing.fails_on('sqlite', "Can't handle this style of nesting") + @testing.requires.except_ def test_except_style3(self): # aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc e = except_( @@ -1217,9 +1212,7 @@ class CompoundTest(TestBase): eq_(e.alias('foo').select().execute().fetchall(), [('ccc',)]) - @testing.crashes('firebird', 'Does not support except') - @testing.crashes('sybase', 'FIXME: unknown, verify not fails_on') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.except_ def test_except_style4(self): # aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc e = except_( @@ -1236,8 +1229,7 @@ class CompoundTest(TestBase): [('ccc',)] ) - @testing.crashes('firebird', 'Does not support intersect') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.intersect @testing.fails_on('sqlite', "sqlite can't handle leading parenthesis") def test_intersect_unions(self): u = intersect( @@ -1255,8 +1247,7 @@ class CompoundTest(TestBase): eq_(found, wanted) - @testing.crashes('firebird', 'Does not support intersect') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.intersect def test_intersect_unions_2(self): u = intersect( union( @@ -1273,9 +1264,8 @@ class CompoundTest(TestBase): eq_(found, wanted) - @testing.crashes('firebird', 'Does not support intersect') - @testing.fails_on('mysql', 'FIXME: unknown') - def test_intersect(self): + @testing.requires.intersect + def test_intersect_unions_3(self): u = intersect( select([t2.c.col3, t2.c.col4]), union( @@ -1289,8 +1279,7 @@ class CompoundTest(TestBase): eq_(found, wanted) - @testing.crashes('firebird', 'Does not support intersect') - @testing.fails_on('mysql', 'FIXME: unknown') + @testing.requires.intersect def test_composite_alias(self): ua = intersect( select([t2.c.col3, t2.c.col4]), @@ -1584,7 +1573,7 @@ class OperatorTest(TestBase): global metadata, flds metadata = MetaData(testing.db) flds = Table('flds', metadata, - Column('idcol', Integer, Sequence('t1pkseq'), primary_key=True), + Column('idcol', Integer, primary_key=True, test_needs_autoincrement=True), Column('intcol', Integer), Column('strcol', String(50)), ) @@ -1598,8 +1587,9 @@ class OperatorTest(TestBase): @classmethod def teardown_class(cls): metadata.drop_all() - - @testing.fails_on('maxdb', 'FIXME: unknown') + + # TODO: seems like more tests warranted for this setup. + def test_modulo(self): eq_( select([flds.c.intcol % 3], diff --git a/test/sql/test_select.py b/test/sql/test_select.py index d27819c18..c97685dcb 100644 --- a/test/sql/test_select.py +++ b/test/sql/test_select.py @@ -1004,6 +1004,12 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A "SELECT mytable.myid IN (4, 5, 6) AS anon_1 FROM mytable", dialect=dialect ) + + self.assert_compile( + select([func.mod(table1.c.myid, 5)]), + "SELECT mod(mytable.myid, 5) AS mod_1 FROM mytable", + dialect=dialect + ) self.assert_compile( select([literal("foo").in_([])]), |