summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew <36489577+recvfrom@users.noreply.github.com>2019-09-19 22:23:33 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-20 08:17:27 +0200
commit3346b78a8a872286a245d1e77ef4718fc5e6be1a (patch)
treed677a6b5d3f8c95057aba2b1abc5d26eb5d9799f
parentbae05bcf68710cb6dafa51325c3ec83ddda83c39 (diff)
Fixed #30786 -- Used CONVERT_TZ to check if the time zone definitions are installed on MySQL.
Replaced a timezone check in the MySQL backend with one that doesn't require access to the mysql.time_zone database.
-rw-r--r--django/db/backends/mysql/features.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py
index 94b57ae57f..82d3eef867 100644
--- a/django/db/backends/mysql/features.py
+++ b/django/db/backends/mysql/features.py
@@ -69,10 +69,11 @@ class DatabaseFeatures(BaseDatabaseFeatures):
@cached_property
def has_zoneinfo_database(self):
- # Test if the time zone definitions are installed.
+ # Test if the time zone definitions are installed. CONVERT_TZ returns
+ # NULL if 'UTC' timezone isn't loaded into the mysql.time_zone.
with self.connection.cursor() as cursor:
- cursor.execute("SELECT 1 FROM mysql.time_zone LIMIT 1")
- return cursor.fetchone() is not None
+ cursor.execute("SELECT CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC')")
+ return cursor.fetchone()[0] is not None
@cached_property
def is_sql_auto_is_null_enabled(self):