From c5a2f48bed44e024fa9cf9512ad948af9bcbad96 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Fri, 8 Dec 2017 19:53:27 +0500 Subject: [PATCH] Improved performance of loading DateTimeField on Oracle and MySQL. --- django/db/backends/mysql/operations.py | 6 +++--- django/db/backends/oracle/operations.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 474cd8d467..fff72e056c 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -219,7 +219,8 @@ class DatabaseOperations(BaseDatabaseOperations): elif internal_type in ['BooleanField', 'NullBooleanField']: converters.append(self.convert_booleanfield_value) elif internal_type == 'DateTimeField': - converters.append(self.convert_datetimefield_value) + if settings.USE_TZ: + converters.append(self.convert_datetimefield_value) elif internal_type == 'UUIDField': converters.append(self.convert_uuidfield_value) return converters @@ -236,8 +237,7 @@ class DatabaseOperations(BaseDatabaseOperations): def convert_datetimefield_value(self, value, expression, connection): if value is not None: - if settings.USE_TZ: - value = timezone.make_aware(value, self.connection.timezone) + value = timezone.make_aware(value, self.connection.timezone) return value def convert_uuidfield_value(self, value, expression, connection): diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index fa29a8925a..fd4206d57f 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -153,7 +153,8 @@ END; elif internal_type in ['BooleanField', 'NullBooleanField']: converters.append(self.convert_booleanfield_value) elif internal_type == 'DateTimeField': - converters.append(self.convert_datetimefield_value) + if settings.USE_TZ: + converters.append(self.convert_datetimefield_value) elif internal_type == 'DateField': converters.append(self.convert_datefield_value) elif internal_type == 'TimeField': @@ -192,8 +193,7 @@ END; def convert_datetimefield_value(self, value, expression, connection): if value is not None: - if settings.USE_TZ: - value = timezone.make_aware(value, self.connection.timezone) + value = timezone.make_aware(value, self.connection.timezone) return value def convert_datefield_value(self, value, expression, connection):