diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-23 18:09:18 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-23 18:09:18 -0400 |
| commit | 444abbe84722e52ff453542e65a6d8e2208cbc50 (patch) | |
| tree | 9c6b5682614c1c5834cd13af8a0ed50659c59b75 /test/sql | |
| parent | e1d09859c55576f507e75960504719d17a46779c (diff) | |
| download | sqlalchemy-444abbe84722e52ff453542e65a6d8e2208cbc50.tar.gz | |
- got firebird running
- add some failure cases
- [bug] Firebird now uses strict "ansi bind rules"
so that bound parameters don't render in the
columns clause of a statement - they render
literally instead.
- [bug] Support for passing datetime as date when
using the DateTime type with Firebird; other
dialects support this.
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_case_statement.py | 20 | ||||
| -rw-r--r-- | test/sql/test_query.py | 8 | ||||
| -rw-r--r-- | test/sql/test_types.py | 34 |
3 files changed, 39 insertions, 23 deletions
diff --git a/test/sql/test_case_statement.py b/test/sql/test_case_statement.py index 994016c2f..7b8ae88db 100644 --- a/test/sql/test_case_statement.py +++ b/test/sql/test_case_statement.py @@ -98,8 +98,10 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL): assert_raises(exc.ArgumentError, case, [("x", "y")]) - self.assert_compile(case([("x", "y")], value=t.c.col1), "CASE test.col1 WHEN :param_1 THEN :param_2 END") - self.assert_compile(case([(t.c.col1==7, "y")], else_="z"), "CASE WHEN (test.col1 = :col1_1) THEN :param_1 ELSE :param_2 END") + self.assert_compile(case([("x", "y")], value=t.c.col1), + "CASE test.col1 WHEN :param_1 THEN :param_2 END") + self.assert_compile(case([(t.c.col1 == 7, "y")], else_="z"), + "CASE WHEN (test.col1 = :col1_1) THEN :param_1 ELSE :param_2 END") def test_text_doesnt_explode(self): @@ -113,10 +115,16 @@ class CaseTest(fixtures.TestBase, AssertsCompiledSQL): ))]).order_by(info_table.c.info), ]: - eq_(s.execute().fetchall(), [ - (u'no', ), (u'no', ), (u'no', ), (u'yes', ), - (u'no', ), (u'no', ), - ]) + if testing.against("firebird"): + eq_(s.execute().fetchall(), [ + ('no ', ), ('no ', ), ('no ', ), ('yes', ), + ('no ', ), ('no ', ), + ]) + else: + eq_(s.execute().fetchall(), [ + ('no', ), ('no', ), ('no', ), ('yes', ), + ('no', ), ('no', ), + ]) diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 642da8dec..70e3e97a8 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -234,7 +234,6 @@ class QueryTest(fixtures.TestBase): l.append(row) self.assert_(len(l) == 3) - @testing.fails_on('firebird', "kinterbasdb doesn't send full type information") @testing.requires.subqueries def test_anonymous_rows(self): users.insert().execute( @@ -710,7 +709,7 @@ class QueryTest(fixtures.TestBase): use_labels=labels), [(3, 'a'), (2, 'b'), (1, None)]) - @testing.fails_on('mssql+pyodbc', + @testing.fails_on('mssql+pyodbc', "pyodbc result row doesn't support slicing") def test_column_slices(self): users.insert().execute(user_id=1, user_name='john') @@ -1203,7 +1202,6 @@ class QueryTest(fixtures.TestBase): assert len(r) == 0 @testing.emits_warning('.*empty sequence.*') - @testing.fails_on('firebird', 'uses sql-92 bind rules') def test_literal_in(self): """similar to test_bind_in but use a bind with a value.""" @@ -1414,7 +1412,7 @@ class TableInsertTest(fixtures.TablesTest): returning=(1, 5) ) - @testing.fails_on('mssql', + @testing.fails_on('mssql', "lowercase table doesn't support identity insert disable") def test_direct_params(self): t = self._fixture() @@ -1424,7 +1422,7 @@ class TableInsertTest(fixtures.TablesTest): inserted_primary_key=[] ) - @testing.fails_on('mssql', + @testing.fails_on('mssql', "lowercase table doesn't support identity insert disable") @testing.requires.returning def test_direct_params_returning(self): diff --git a/test/sql/test_types.py b/test/sql/test_types.py index e00c08ad2..ff22ea4de 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -818,7 +818,7 @@ class UnicodeTest(fixtures.TestBase, AssertsExecutionResults): # lambda: testing.db_spec("postgresql")(testing.db), # "pg8000 and psycopg2 both have issues here in py3k" # ) - @testing.skip_if(lambda: testing.db_spec('mssql+mxodbc'), + @testing.skip_if(lambda: testing.db_spec('mssql+mxodbc'), "unsupported behavior") def test_ignoring_unicode_error(self): """checks String(unicode_error='ignore') is passed to underlying codec.""" @@ -1023,7 +1023,7 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults): __excluded_on__ = ( ('mysql', '<', (4, 1, 1)), # screwy varbinary types ) - + @classmethod def setup_class(cls): global binary_table, MyPickleType, metadata @@ -1140,7 +1140,7 @@ class ExpressionTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled return value / 10 return process def adapt_operator(self, op): - return {operators.add:operators.sub, + return {operators.add:operators.sub, operators.sub:operators.add}.get(op, op) class MyTypeDec(types.TypeDecorator): @@ -1498,7 +1498,7 @@ class DateTest(fixtures.TestBase, AssertsExecutionResults): def teardown_class(cls): users_with_date.drop() - def testdate(self): + def test_date_roundtrip(self): global insert_data l = map(tuple, @@ -1506,10 +1506,10 @@ class DateTest(fixtures.TestBase, AssertsExecutionResults): self.assert_(l == insert_data, 'DateTest mismatch: got:%s expected:%s' % (l, insert_data)) - def testtextdate(self): + def test_text_date_roundtrip(self): x = testing.db.execute(text( "select user_datetime from query_users_with_date", - typemap={'user_datetime':DateTime})).fetchall() + typemap={'user_datetime': DateTime})).fetchall() self.assert_(isinstance(x[0][0], datetime.datetime)) @@ -1518,13 +1518,14 @@ class DateTest(fixtures.TestBase, AssertsExecutionResults): bindparams=[bindparam('somedate', type_=types.DateTime)]), somedate=datetime.datetime(2005, 11, 10, 11, 52, 35)).fetchall() - def testdate2(self): + def test_date_mixdatetime_roundtrip(self): meta = MetaData(testing.db) t = Table('testdate', meta, - Column('id', Integer, + Column('id', Integer, Sequence('datetest_id_seq', optional=True), primary_key=True), - Column('adate', Date), Column('adatetime', DateTime)) + Column('adate', Date), + Column('adatetime', DateTime)) t.create(checkfirst=True) try: d1 = datetime.date(2007, 10, 30) @@ -1540,8 +1541,14 @@ class DateTest(fixtures.TestBase, AssertsExecutionResults): # test mismatched date/datetime t.insert().execute(adate=d2, adatetime=d2) - eq_(select([t.c.adate, t.c.adatetime], t.c.adate==d1).execute().fetchall(), [(d1, d2)]) - eq_(select([t.c.adate, t.c.adatetime], t.c.adate==d1).execute().fetchall(), [(d1, d2)]) + eq_( + select([t.c.adate, t.c.adatetime], t.c.adate == d1)\ + .execute().fetchall(), + [(d1, d2)]) + eq_( + select([t.c.adate, t.c.adatetime], t.c.adate == d1)\ + .execute().fetchall(), + [(d1, d2)]) finally: t.drop(checkfirst=True) @@ -1705,6 +1712,9 @@ class NumericTest(fixtures.TestBase): ) @testing.fails_on('postgresql+pg8000', "pg-8000 does native decimal but truncates the decimals.") + @testing.fails_on("firebird", + "database and/or driver truncates decimal places." + ) def test_numeric_no_decimal(self): numbers = set([ decimal.Decimal("1.000") @@ -1762,7 +1772,7 @@ class NumericRawSQLTest(fixtures.TestBase): assert isinstance(val, float) # some DBAPIs have unusual float handling - if testing.against('oracle+cx_oracle', 'mysql+oursql'): + if testing.against('oracle+cx_oracle', 'mysql+oursql', 'firebird'): eq_(round_decimal(val, 3), 46.583) else: eq_(val, 46.583) |
