diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-27 20:03:33 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-27 20:03:33 +0000 |
| commit | cd6af2e03b8ffba0c7d6b8906c178fd1aa742920 (patch) | |
| tree | 4da300a9f8441274624b3db49236322476954c07 /test | |
| parent | 8b1096eea4fdc081a803279c57226ac07481d788 (diff) | |
| download | sqlalchemy-cd6af2e03b8ffba0c7d6b8906c178fd1aa742920.tar.gz | |
working on pyodbc / mxodbc
Diffstat (limited to 'test')
| -rw-r--r-- | test/dialect/test_mssql.py | 24 | ||||
| -rw-r--r-- | test/engine/test_reflection.py | 5 | ||||
| -rw-r--r-- | test/sql/test_query.py | 13 | ||||
| -rw-r--r-- | test/sql/test_returning.py | 3 | ||||
| -rw-r--r-- | test/sql/test_rowcount.py | 7 | ||||
| -rw-r--r-- | test/sql/test_types.py | 8 |
6 files changed, 42 insertions, 18 deletions
diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py index aa5ecf8cd..caf71ab10 100644 --- a/test/dialect/test_mssql.py +++ b/test/dialect/test_mssql.py @@ -214,7 +214,7 @@ class CompileTest(TestBase, AssertsCompiledSQL): class IdentityInsertTest(TestBase, AssertsCompiledSQL): __only_on__ = 'mssql' - __dialect__ = mssql.MSSQLDialect() + __dialect__ = mssql.MSDialect() @classmethod def setup_class(cls): @@ -322,7 +322,8 @@ class ReflectionTest(TestBase, ComparesTables): meta2 = MetaData(testing.db) try: table2 = Table('identity_test', meta2, autoload=True) - sequence = isinstance(table2.c['col1'].default, schema.Sequence) and table2.c['col1'].default + sequence = isinstance(table2.c['col1'].default, schema.Sequence) \ + and table2.c['col1'].default assert sequence.start == 2 assert sequence.increment == 3 finally: @@ -704,7 +705,8 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): '0.0000000000000000002', '0.2', '-0.0000000000000000002', '-2E-2', '156666.458923543', '-156666.458923543', '1', '-1', '-1234', '1234', '2E-12', '4E8', '3E-6', '3E-7', '4.1', '1E-1', '1E-2', '1E-3', - '1E-4', '1E-5', '1E-6', '1E-7', '1E-1', '1E-8', '0.2732E2', '-0.2432E2', '4.35656E2', + '1E-4', '1E-5', '1E-6', '1E-7', '1E-1', '1E-8', '0.2732E2', + '-0.2432E2', '4.35656E2', '-02452E-2', '45125E-2', '1234.58965E-2', '1.521E+15', '-1E-25', '1E-25', '1254E-25', '-1203E-25', '0', '-0.00', '-0', '4585E12', '000000000000000000012', '000000000000.32E12', @@ -714,7 +716,7 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): numeric_table.insert().execute(numericcol=value) for value in select([numeric_table.c.numericcol]).execute(): - assert value[0] in test_items, "%s not in test_items" % value[0] + assert value[0] in test_items, "%r not in test_items" % value[0] def test_float(self): float_table = Table('float_table', metadata, @@ -1071,16 +1073,17 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): testing.eq_(gen.get_column_specification(t.c.t), "t %s" % expected) self.assert_(repr(t.c.t)) t.create(checkfirst=True) - + + @testing.crashes("+mxodbc", "mxODBC doesn't do scope_identity() with DEFAULT VALUES") def test_autoincrement(self): Table('ai_1', metadata, Column('int_y', Integer, primary_key=True), Column('int_n', Integer, DefaultClause('0'), - primary_key=True)) + primary_key=True, autoincrement=False)) Table('ai_2', metadata, Column('int_y', Integer, primary_key=True), Column('int_n', Integer, DefaultClause('0'), - primary_key=True)) + primary_key=True, autoincrement=False)) Table('ai_3', metadata, Column('int_n', Integer, DefaultClause('0'), primary_key=True, autoincrement=False), @@ -1117,11 +1120,14 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables): for name in table_names: tbl = Table(name, mr, autoload=True) + tbl = metadata.tables[name] for c in tbl.c: if c.name.startswith('int_y'): - assert c.autoincrement + assert c.autoincrement, name + assert tbl._autoincrement_column is c, name elif c.name.startswith('int_n'): - assert not c.autoincrement + assert not c.autoincrement, name + assert tbl._autoincrement_column is not c, name for counter, engine in enumerate([ engines.testing_engine(options={'implicit_returning':False}), diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index 5d3f0ca86..bf94cce65 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -804,12 +804,13 @@ class UnicodeReflectionTest(TestBase): metadata = MetaData(bind) if testing.against('sybase', 'maxdb', 'oracle', 'mssql'): - names = set(['plain']) + names = set([u'plain']) else: names = set([u'plain', u'Unit\u00e9ble', u'\u6e2c\u8a66']) for name in names: - Table(name, metadata, Column('id', sa.Integer, sa.Sequence(name + "_id_seq"), primary_key=True)) + Table(name, metadata, Column('id', sa.Integer, sa.Sequence(name + "_id_seq"), + primary_key=True)) metadata.create_all() reflected = set(bind.table_names()) diff --git a/test/sql/test_query.py b/test/sql/test_query.py index d7bca1af4..62da772a4 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -78,6 +78,13 @@ class QueryTest(TestBase): detects rows that had defaults and post-fetches. """ + # verify implicit_returning is working + if engine.dialect.implicit_returning: + ins = table.insert() + comp = ins.compile(engine, column_keys=list(values)) + if not set(values).issuperset(c.key for c in table.primary_key): + assert comp.returning + result = engine.execute(table.insert(), **values) ret = values.copy() @@ -85,13 +92,17 @@ class QueryTest(TestBase): ret[col.key] = id if result.lastrow_has_defaults(): - criterion = and_(*[col==id for col, id in zip(table.primary_key, result.inserted_primary_key)]) + criterion = and_(*[col==id for col, id in + zip(table.primary_key, result.inserted_primary_key)]) row = engine.execute(table.select(criterion)).first() for c in table.c: ret[c.key] = row[c] return ret if testing.against('firebird', 'postgresql', 'oracle', 'mssql'): + assert testing.db.dialect.implicit_returning + + if testing.db.dialect.implicit_returning: test_engines = [ engines.testing_engine(options={'implicit_returning':False}), engines.testing_engine(options={'implicit_returning':True}), diff --git a/test/sql/test_returning.py b/test/sql/test_returning.py index a36ce3cd8..481eba825 100644 --- a/test/sql/test_returning.py +++ b/test/sql/test_returning.py @@ -95,6 +95,7 @@ class ReturningTest(TestBase, AssertsExecutionResults): @testing.fails_on('postgresql', '') @testing.fails_on('oracle', '') + @testing.crashes('mssql+mxodbc', 'Raises an error') def test_executemany(): # return value is documented as failing with psycopg2/executemany result2 = table.insert().returning(table).execute( @@ -112,8 +113,6 @@ class ReturningTest(TestBase, AssertsExecutionResults): test_executemany() - result3 = table.insert().returning(table.c.id).execute({'persons': 4, 'full': False}) - eq_([dict(row) for row in result3], [{'id': 4}]) @testing.exclude('firebird', '<', (2, 1), '2.1+ feature') diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py index 82301a4a5..6da25b914 100644 --- a/test/sql/test_rowcount.py +++ b/test/sql/test_rowcount.py @@ -4,6 +4,9 @@ from sqlalchemy.test import * class FoundRowsTest(TestBase, AssertsExecutionResults): """tests rowcount functionality""" + + __requires__ = ('sane_rowcount', ) + @classmethod def setup_class(cls): metadata = MetaData(testing.db) @@ -11,7 +14,9 @@ class FoundRowsTest(TestBase, AssertsExecutionResults): global employees_table employees_table = Table('employees', metadata, - Column('employee_id', Integer, Sequence('employee_id_seq', optional=True), primary_key=True), + Column('employee_id', Integer, + Sequence('employee_id_seq', optional=True), + primary_key=True), Column('name', String(50)), Column('department', String(1)), ) diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 53f4d8d91..29b337eda 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -112,7 +112,7 @@ class PickleMetadataTest(TestBase): class UserDefinedTest(TestBase): """tests user-defined types.""" - def testprocessing(self): + def test_processing(self): global users users.insert().execute( @@ -132,7 +132,7 @@ class UserDefinedTest(TestBase): [1800, 2250, 1350], l ): - for col in row[1:5]: + for col in list(row)[1:5]: eq_(col, assertstr) eq_(row[5], assertint) eq_(row[6], assertint2) @@ -1113,7 +1113,7 @@ class BooleanTest(TestBase, AssertsExecutionResults): global bool_table metadata = MetaData(testing.db) bool_table = Table('booltest', metadata, - Column('id', Integer, primary_key=True), + Column('id', Integer, primary_key=True, autoincrement=False), Column('value', Boolean), Column('unconstrained_value', Boolean(create_constraint=False)), ) @@ -1156,6 +1156,8 @@ class BooleanTest(TestBase, AssertsExecutionResults): @testing.fails_on('mysql', "The CHECK clause is parsed but ignored by all storage engines.") + @testing.fails_on('mssql', + "FIXME: MS-SQL 2005 doesn't honor CHECK ?!?") @testing.skip_if(lambda: testing.db.dialect.supports_native_boolean) def test_constraint(self): assert_raises((exc.IntegrityError, exc.ProgrammingError), |
