From a20ce1a8fe8d8142edfca8586a7f08e4047ec4ff Mon Sep 17 00:00:00 2001 From: Iggy Eom Date: Wed, 20 May 2020 16:31:47 +0900 Subject: [PATCH] Revert microsecond precision support. This commit partially reverts 22da5f8817ffff3917bcf8a652dce84f382c9202 --- django/db/backends/mysql/base.py | 11 ++--------- django/db/backends/mysql/features.py | 7 +------ 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 03f38576646d..732eb428c3bd 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -64,7 +64,7 @@ def adapt_datetime_warn_on_aware_datetime(value, conv): # This doesn't account for the database connection's timezone, # which isn't known. (That's why this adapter is deprecated.) value = value.astimezone(timezone.utc).replace(tzinfo=None) - return Thing2Literal(value.strftime("%Y-%m-%d %H:%M:%S.%f"), conv) + return Thing2Literal(value.strftime("%Y-%m-%d %H:%M:%S"), conv) # MySQLdb-1.2.1 returns TIME columns as timedelta -- they are more like # timedelta in terms of actual behavior as they are signed and include days -- @@ -151,7 +151,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): # types, as strings. Column-type strings can contain format strings; they'll # be interpolated against the values of Field.__dict__ before being output. # If a column type is set to None, it won't be included in the output. - _data_types = { + data_types = { 'AutoField': 'integer AUTO_INCREMENT', 'BinaryField': 'longblob', 'BooleanField': 'bool', @@ -179,13 +179,6 @@ class DatabaseWrapper(BaseDatabaseWrapper): 'UUIDField': 'char(32)', } - @cached_property - def data_types(self): - if self.features.supports_microsecond_precision: - return dict(self._data_types, DateTimeField='datetime(6)', TimeField='time(6)') - else: - return self._data_types - operators = { 'exact': '= %s', 'iexact': 'LIKE %s', diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py index c8ea8f7fb67f..8e4fc81ff4b1 100644 --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -19,6 +19,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): has_select_for_update = True has_select_for_update_nowait = False supports_forward_references = False + supports_microsecond_precision = False supports_regex_backreferencing = False supports_date_lookup_using_string = False can_introspect_autofield = True @@ -46,12 +47,6 @@ def can_introspect_foreign_keys(self): "Confirm support for introspected foreign keys" return self._mysql_storage_engine != 'MyISAM' - @cached_property - def supports_microsecond_precision(self): - # See https://github.com/farcepest/MySQLdb1/issues/24 for the reason - # about requiring MySQLdb 1.2.5 - return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5) - @cached_property def has_zoneinfo_database(self): # MySQL accepts full time zones names (eg. Africa/Nairobi) but rejects