--- /dev/null
+.. 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.
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):
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 \
real_warn = warnings.warn
- def our_warn(msg, exception, *arg, **kw):
- if not issubclass(exception, exc_cls):
- return real_warn(msg, exception, *arg, **kw)
+ def our_warn(msg, *arg, **kw):
+ if isinstance(msg, exc_cls):
+ exception = msg
+ msg = str(exception)
+ elif arg:
+ exception = arg[0]
+ else:
+ exception = None
+
+ if not exception or not issubclass(exception, exc_cls):
+ return real_warn(msg, *arg, **kw)
if not filters:
return
seen.discard(filter_)
break
else:
- real_warn(msg, exception, *arg, **kw)
+ real_warn(msg, *arg, **kw)
with mock.patch("warnings.warn", our_warn):
yield