Skip to content

Commit

Permalink
Revert microsecond precision support.
Browse files Browse the repository at this point in the history
This commit partially reverts 22da5f8
  • Loading branch information
thebarbershop committed May 21, 2020
1 parent 82036a5 commit a20ce1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
11 changes: 2 additions & 9 deletions django/db/backends/mysql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 1 addition & 6 deletions django/db/backends/mysql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a20ce1a

Please sign in to comment.