From 7325393c9297f08319c43728ddbd1936a89cd950 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 f31697dadcbf..77a639b9c1b3 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -73,7 +73,7 @@ def adapt_datetime_with_timezone_support(value, conv): default_timezone = timezone.get_default_timezone() value = timezone.make_aware(value, default_timezone) 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 -- @@ -163,7 +163,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', @@ -191,13 +191,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 8f2e99a79165..9c716b4f8a05 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 @@ -45,12 +46,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