Fixed #27180 -- Fixed a crash in MySQL checks where SELECT @@sql_mode doesn't return a result.

This commit is contained in:
Markus Gerards 2016-09-07 13:43:51 +02:00 committed by Tim Graham
parent 8cae9bb772
commit 2b64ff68cc
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,7 @@ class DatabaseValidation(BaseDatabaseValidation):
with self.connection.cursor() as cursor: with self.connection.cursor() as cursor:
cursor.execute("SELECT @@sql_mode") cursor.execute("SELECT @@sql_mode")
sql_mode = cursor.fetchone() sql_mode = cursor.fetchone()
modes = set(sql_mode[0].split(',')) modes = set(sql_mode[0].split(',') if sql_mode else ())
if not (modes & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}): if not (modes & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
return [checks.Warning( return [checks.Warning(
"MySQL Strict Mode is not set for database connection '%s'" % self.connection.alias, "MySQL Strict Mode is not set for database connection '%s'" % self.connection.alias,

View File

@ -9,4 +9,5 @@ Django 1.10.2 fixes several bugs in 1.10.1.
Bugfixes Bugfixes
======== ========
* ... * Fixed a crash in MySQL database validation where ``SELECT @@sql_mode``
doesn't return a result (:ticket:`27180`).