]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
grab lastrowid on a different cursor so we don't munge the original's state
authorPhilip Jenvey <pjenvey@underboss.org>
Fri, 24 Jul 2009 04:12:10 +0000 (04:12 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Fri, 24 Jul 2009 04:12:10 +0000 (04:12 +0000)
lib/sqlalchemy/dialects/mysql/pyodbc.py
lib/sqlalchemy/dialects/mysql/zxjdbc.py

index de419fbd89d0fba898249211205ca9e273a8b42f..4896173e45108b65ccc35e218fd5dfd4b44184a4 100644 (file)
@@ -6,8 +6,11 @@ import re
 
 class MySQL_pyodbcExecutionContext(MySQLExecutionContext):
     def _lastrowid(self, cursor):
+        cursor = self.create_cursor()
         cursor.execute("SELECT LAST_INSERT_ID()")
-        return cursor.fetchone()[0]
+        lastrowid = cursor.fetchone()[0]
+        cursor.close()
+        return lastrowid
 
 class MySQL_pyodbc(PyODBCConnector, MySQLDialect):
     supports_unicode_statements = False
@@ -47,4 +50,4 @@ class MySQL_pyodbc(PyODBCConnector, MySQLDialect):
         else:
             return None
 
-dialect = MySQL_pyodbc
\ No newline at end of file
+dialect = MySQL_pyodbc
index c7ebfc85a7fef2b9b780fa69a2632dd42c95f9c3..09e09afec55d510e67fcec21115f48a605b92aae 100644 (file)
@@ -8,8 +8,11 @@ class MySQL_jdbcExecutionContext(MySQLExecutionContext):
         return cursor.lastrowid
 
     def _lastrowid(self, cursor):
+        cursor = self.create_cursor()
         cursor.execute("SELECT LAST_INSERT_ID()")
-        return cursor.fetchone()[0]
+        lastrowid = cursor.fetchone()[0]
+        cursor.close()
+        return lastrowid
 
 class MySQL_jdbc(ZxJDBCConnector, MySQLDialect):
     execution_ctx_cls = MySQL_jdbcExecutionContext
@@ -61,4 +64,4 @@ class MySQL_jdbc(ZxJDBCConnector, MySQLDialect):
                 version.append(n)
         return tuple(version)
 
-dialect = MySQL_jdbc
\ No newline at end of file
+dialect = MySQL_jdbc