]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
some ms/odbc fixes
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Feb 2010 21:29:20 +0000 (21:29 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Feb 2010 21:29:20 +0000 (21:29 +0000)
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/test/requires.py
test/dialect/test_mssql.py
test/engine/test_pool.py
test/engine/test_transaction.py

index 988088faedece8663d4f31d80f4796b4326120f3..d1ccf44e2c7194edcfda121c7e1f5c0eba203e2e 100644 (file)
@@ -803,9 +803,9 @@ class MSExecutionContext(default.DefaultExecutionContext):
         
         if self._select_lastrowid:
             if self.dialect.use_scope_identity:
-                self.cursor.execute("SELECT scope_identity() AS lastrowid")
+                self.cursor.execute("SELECT scope_identity() AS lastrowid", ())
             else:
-                self.cursor.execute("SELECT @@identity AS lastrowid")
+                self.cursor.execute("SELECT @@identity AS lastrowid", ())
             # fetchall() ensures the cursor is consumed without closing it
             row = self.cursor.fetchall()[0]
             self._lastrowid = int(row[0])
index 0bf4689dfe49d59ddbadbb3bcbbe83777bb47363..6cfab18ce84b90feb4bf06c1193771067e1fd4ce 100644 (file)
@@ -66,6 +66,15 @@ def identity(fn):
         no_support('sybase', 'not supported by database'),
         )
 
+def independent_cursors(fn):
+    """Target must support simultaneous, independent database cursors on a single connection."""
+
+    return _chain_decorators_on(
+        fn,
+        no_support('mssql+pyodbc', 'no driver support'),
+        no_support('mssql+mxodbc', 'no driver support'),
+        )
+
 def independent_connections(fn):
     """Target must support simultaneous, independent database connections."""
 
index caf71ab1031cd5ad12ed9958fb033b35a5f8c0cf..f7728c8845eb8f94adfc18c6821cef885fdeac33 100644 (file)
@@ -692,6 +692,7 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables):
     def teardown(self):
         metadata.drop_all()
 
+    @testing.fails_on_everything_except('mssql+pyodbc', 'this is some pyodbc-specific feature')
     def test_decimal_notation(self):
         import decimal
         numeric_table = Table('numeric_table', metadata,
@@ -1074,7 +1075,6 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables):
         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),
@@ -1129,11 +1129,16 @@ class TypesTest(TestBase, AssertsExecutionResults, ComparesTables):
                     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}),
-                engines.testing_engine(options={'implicit_returning':True}),
-                ]
-            ):
+            # mxodbc can't handle scope_identity() with DEFAULT VALUES
+            if testing.db.driver == 'mxodbc':
+                eng = [engines.testing_engine(options={'implicit_returning':True})]
+            else:
+                eng = [
+                    engines.testing_engine(options={'implicit_returning':False}),
+                    engines.testing_engine(options={'implicit_returning':True}),
+                    ]
+                    
+            for counter, engine in enumerate(eng):
                 engine.execute(tbl.insert())
                 if 'int_y' in tbl.c:
                     assert engine.scalar(select([tbl.c.int_y])) == counter + 1
index 2b6ee5e58da36d4f15ee25b04d69fecca35596c5..44b9a94cf44e76ab2f5e58b944267c8d0f1b6232 100644 (file)
@@ -73,6 +73,7 @@ class PoolTest(PoolTestBase):
         self.assert_(connection.cursor() is not None)
         self.assert_(connection is not connection2)
 
+    @testing.fails_on('+pyodbc', "pyodbc cursor doesn't implement tuple __eq__")
     def test_cursor_iterable(self):
         conn = testing.db.raw_connection()
         cursor = conn.cursor()
index 84ffaf455de8b3ed6d9ed1339f175deddb8922b8..e8da89438151d7ca4a36d13a83822b64cd1c0e01 100644 (file)
@@ -850,7 +850,8 @@ class TLTransactionTest(TestBase):
         c2.close()
         assert not c1.closed
         assert not tlengine.closed
-        
+
+    @testing.requires.independent_cursors
     def test_result_closing(self):
         """tests that contextual_connect is threadlocal"""