From: Daniel Thorell <(none)> Date: Fri, 20 Oct 2017 16:59:55 +0000 (-0400) Subject: Remove deprecation warnings mysql5 7 20 X-Git-Tag: rel_1_2_0~47^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41cfe44b5e5806b3d3b13949e41dbb347bfa29e1;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Remove deprecation warnings mysql5 7 20 MySQL 5.7.20 now warns for use of the @tx_isolation variable; a version check is now performed and uses @transaction_isolation instead to prevent this warning. Co-authored by: Mike Bayer Fixes: #4120 Change-Id: I4d2e04df760c5351a71dde8b32145cdc69fa6115 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/391 --- diff --git a/doc/build/changelog/unreleased_11/4120.rst b/doc/build/changelog/unreleased_11/4120.rst new file mode 100644 index 0000000000..e84c1ac194 --- /dev/null +++ b/doc/build/changelog/unreleased_11/4120.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, mysql + :tickets: 4120 + :versions: 1.2.0b4 + + MySQL 5.7.20 now warns for use of the @tx_isolation variable; a version + check is now performed and uses @transaction_isolation instead + to prevent this warning. diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 5f0b45a45d..188276b6a3 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -1720,7 +1720,10 @@ class MySQLDialect(default.DefaultDialect): def get_isolation_level(self, connection): cursor = connection.cursor() - cursor.execute('SELECT @@tx_isolation') + if self._is_mysql and self.server_version_info >= (5, 7, 20): + cursor.execute('SELECT @@transaction_isolation') + else: + cursor.execute('SELECT @@tx_isolation') val = cursor.fetchone()[0] cursor.close() if util.py3k and isinstance(val, bytes): @@ -1887,6 +1890,10 @@ class MySQLDialect(default.DefaultDialect): def _is_mariadb(self): return 'MariaDB' in self.server_version_info + @property + def _is_mysql(self): + return 'MariaDB' not in self.server_version_info + @property def _is_mariadb_102(self): return self._is_mariadb and \