Skip to content

Commit

Permalink
Re-enable microsecond precision for DateTimeField. (#1)
Browse files Browse the repository at this point in the history
* Add information of sendbird forks.

* Re-enable millisecond precision for time fields.

* Bump version to 1.9.16.

* Add soda update information.
  • Loading branch information
thebarbershop authored Sep 16, 2020
1 parent 7683286 commit fe1adb1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
27 changes: 27 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,30 @@ To run Django's test suite:
* Follow the instructions in the "Unit tests" section of
docs/internals/contributing/writing-code/unit-tests.txt, published online at
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests

*****************
The SendBird Fork
*****************

1.9.13 is the last minor version of upstream Django 1.9.

1.9.14
======

This version does not exist.

1.9.15
======

`Soda <https://github.com/sendbird/soda>`_ uses this fork since v0.28. (See `sendbird/soda#6667 <https://github.com/sendbird/soda/pull/6667>`_)

* Fixed Python 3.6 deprecation warning for empty model `super()` calls. (82036a5)
* Reverted the upstream microsecond precision support (a20ce1a)
* Suppressed the upstream update of nullable `User.last_login` (1cb5bc2)

1.9.16
======

`Soda <https://github.com/sendbird/soda>`_ uses this fork since v0.33. (See `sendbird/soda#7711 <https://github.com/sendbird/soda/pull/7711>`_)

* Re-enabled the upstream microsecond precision support. (1b55425)
2 changes: 1 addition & 1 deletion django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.utils.version import get_version

VERSION = (1, 9, 15, 'alpha', 0)
VERSION = (1, 9, 16, 'alpha', 0)

__version__ = get_version(VERSION)

Expand Down
11 changes: 9 additions & 2 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"), conv)
return Thing2Literal(value.strftime("%Y-%m-%d %H:%M:%S.%f"), 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,6 +179,13 @@ 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: 6 additions & 1 deletion django/db/backends/mysql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ 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 All @@ -42,6 +41,12 @@ def _mysql_storage_engine(self):
result = cursor.fetchone()
return result[0]

@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 can_introspect_foreign_keys(self):
"Confirm support for introspected foreign keys"
Expand Down

0 comments on commit fe1adb1

Please sign in to comment.