summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py4
-rw-r--r--lib/sqlalchemy/test/requires.py9
-rw-r--r--test/dialect/test_mssql.py17
-rw-r--r--test/engine/test_pool.py1
-rw-r--r--test/engine/test_transaction.py3
5 files changed, 25 insertions, 9 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 988088fae..d1ccf44e2 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -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])
diff --git a/lib/sqlalchemy/test/requires.py b/lib/sqlalchemy/test/requires.py
index 0bf4689df..6cfab18ce 100644
--- a/lib/sqlalchemy/test/requires.py
+++ b/lib/sqlalchemy/test/requires.py
@@ -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."""
diff --git a/test/dialect/test_mssql.py b/test/dialect/test_mssql.py
index caf71ab10..f7728c884 100644
--- a/test/dialect/test_mssql.py
+++ b/test/dialect/test_mssql.py
@@ -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
diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py
index 2b6ee5e58..44b9a94cf 100644
--- a/test/engine/test_pool.py
+++ b/test/engine/test_pool.py
@@ -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()
diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py
index 84ffaf455..e8da89438 100644
--- a/test/engine/test_transaction.py
+++ b/test/engine/test_transaction.py
@@ -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"""