diff options
author | can <cansarigol@derinbilgi.com.tr> | 2019-03-30 00:07:29 +0300 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-04-08 08:59:17 +0200 |
commit | cef3f2d3c64055c9fc1757fd61dba24b557a2add (patch) | |
tree | 4b705eb6959038580f48fbc4f6f515e541c18327 /django/db/backends/mysql/operations.py | |
parent | c84b91b7603e488f7171fdff8f08368ef3d6b856 (diff) | |
download | django-cef3f2d3c64055c9fc1757fd61dba24b557a2add.tar.gz |
Fixed #28373 -- Used connection timezone instead of UTC when making dates timezone-aware on MySQL, SQLite, and Oracle.
Thanks vtalpaert for the initial patch.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/db/backends/mysql/operations.py')
-rw-r--r-- | django/db/backends/mysql/operations.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 50f85e0621..da15e79ec2 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -69,8 +69,8 @@ class DatabaseOperations(BaseDatabaseOperations): return "DATE(%s)" % (field_name) def _convert_field_to_tz(self, field_name, tzname): - if settings.USE_TZ: - field_name = "CONVERT_TZ(%s, 'UTC', '%s')" % (field_name, tzname) + if settings.USE_TZ and self.connection.timezone_name != tzname: + field_name = "CONVERT_TZ(%s, '%s', '%s')" % (field_name, self.connection.timezone_name, tzname) return field_name def datetime_cast_date_sql(self, field_name, tzname): |