]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Modified the do_begin handling in mssql to use the Cursor not the Connection.
authorMichael Trier <mtrier@gmail.com>
Sun, 11 Jan 2009 19:15:30 +0000 (19:15 +0000)
committerMichael Trier <mtrier@gmail.com>
Sun, 11 Jan 2009 19:15:30 +0000 (19:15 +0000)
This corrects a problem where we were trying to call execute on the Connection
object instead of against the cursor. This is supported on pyodbc but not in
the DBAPI. Overrode the behavior in pymssql to not do special do_begin
processing on that dialect.

CHANGES
lib/sqlalchemy/databases/mssql.py

diff --git a/CHANGES b/CHANGES
index 7dbd8933339e537120281737fcfba5083d0caede..bbaa5b33b7f5d95d2f3f38582936a95ff1cbe578 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,10 @@ CHANGES
     - Added the missing keywords from MySQL 4.1 so they get escaped
       properly.
 
+- mssql
+    - Modified the do_begin handling in mssql to use the Cursor not
+      the Connection so it is DBAPI compatible.
+
 0.5.0
 ========
 
index 242fc5efb5318d7bca40d6057a93dbb8865feabb..a3d80c67864f4d164e30133dc06ebe3816484c1d 100644 (file)
@@ -1056,8 +1056,9 @@ class MSSQLDialect(default.DefaultDialect):
         return newobj
 
     def do_begin(self, connection):
-        connection.execute("SET IMPLICIT_TRANSACTIONS OFF")
-        connection.execute("BEGIN TRANSACTION")
+        cursor = connection.cursor()
+        cursor.execute("SET IMPLICIT_TRANSACTIONS OFF")
+        cursor.execute("BEGIN TRANSACTION")
 
     @base.connection_memoize(('dialect', 'default_schema_name'))
     def get_default_schema_name(self, connection):
@@ -1304,6 +1305,9 @@ class MSSQLDialect_pymssql(MSSQLDialect):
     def is_disconnect(self, e):
         return isinstance(e, self.dbapi.DatabaseError) and "Error 10054" in str(e)
 
+    def do_begin(self, connection):
+        pass
+
 
 class MSSQLDialect_pyodbc(MSSQLDialect):
     supports_sane_rowcount = False
@@ -1430,6 +1434,7 @@ class MSSQLDialect_adodbapi(MSSQLDialect):
     def is_disconnect(self, e):
         return isinstance(e, self.dbapi.adodbapi.DatabaseError) and "'connection failure'" in str(e)
 
+
 dialect_mapping = {
     'pymssql':  MSSQLDialect_pymssql,
     'pyodbc':   MSSQLDialect_pyodbc,