From e120837b682a3a822c2dff136ad48b1ca9fb6ce2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 19 Feb 2022 14:11:19 -0500 Subject: updates for mariadb connector 1.0.10 Fixed regression in mariadbconnector dialect as of mariadb connector 1.0.10 where the DBAPI no longer pre-buffers cursor.lastrowid. The dialect now fetches this value proactively for situations where it applies. test_invalidate_on_results seems to pass for mariadbconnector now. the driver has likely changed how it buffers result sets. This is a major change for them to make in a point release so we might want to watch this in case they reverse course again. Fixes: #7738 Change-Id: I9610aae01d1ae42fa92ffbc7123a6948e40ec9dd --- lib/sqlalchemy/dialects/mysql/mariadbconnector.py | 9 +++++++++ lib/sqlalchemy/engine/default.py | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/dialects/mysql/mariadbconnector.py b/lib/sqlalchemy/dialects/mysql/mariadbconnector.py index ea6060c01..fca91204f 100644 --- a/lib/sqlalchemy/dialects/mysql/mariadbconnector.py +++ b/lib/sqlalchemy/dialects/mysql/mariadbconnector.py @@ -39,12 +39,21 @@ mariadb_cpy_minimum_version = (1, 0, 1) class MySQLExecutionContext_mariadbconnector(MySQLExecutionContext): + _lastrowid = None + def create_server_side_cursor(self): return self._dbapi_connection.cursor(buffered=False) def create_default_cursor(self): return self._dbapi_connection.cursor(buffered=True) + def post_exec(self): + if self.isinsert and self.compiled.postfetch_lastrowid: + self._lastrowid = self.cursor.lastrowid + + def get_lastrowid(self): + return self._lastrowid + class MySQLCompiler_mariadbconnector(MySQLCompiler): pass diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index b7dbfc52e..a4dbf2361 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -1383,7 +1383,6 @@ class DefaultExecutionContext(interfaces.ExecutionContext): return self._setup_ins_pk_from_empty() def _setup_ins_pk_from_lastrowid(self): - getter = self.compiled._inserted_primary_key_from_lastrowid_getter lastrowid = self.get_lastrowid() -- cgit v1.2.1