Stopped stripping microseconds with MySQL backend

Refs #19716.
This commit is contained in:
Claude Paroz 2014-08-12 17:23:01 +02:00
parent ae7cb992bc
commit 9e746c13e8
2 changed files with 10 additions and 9 deletions

View File

@ -364,8 +364,7 @@ class DatabaseOperations(BaseDatabaseOperations):
else: else:
raise ValueError("MySQL backend does not support timezone-aware datetimes when USE_TZ is False.") raise ValueError("MySQL backend does not support timezone-aware datetimes when USE_TZ is False.")
# MySQL doesn't support microseconds return six.text_type(value)
return six.text_type(value.replace(microsecond=0))
def value_to_db_time(self, value): def value_to_db_time(self, value):
if value is None: if value is None:
@ -375,13 +374,7 @@ class DatabaseOperations(BaseDatabaseOperations):
if timezone.is_aware(value): if timezone.is_aware(value):
raise ValueError("MySQL backend does not support timezone-aware times.") raise ValueError("MySQL backend does not support timezone-aware times.")
# MySQL doesn't support microseconds return six.text_type(value)
return six.text_type(value.replace(microsecond=0))
def year_lookup_bounds_for_datetime_field(self, value):
# Again, no microseconds
first, second = super(DatabaseOperations, self).year_lookup_bounds_for_datetime_field(value)
return [first.replace(microsecond=0), second.replace(microsecond=0)]
def max_name_length(self): def max_name_length(self):
return 64 return 64

View File

@ -160,6 +160,14 @@ Cache
* The ``incr()`` method of the * The ``incr()`` method of the
``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe. ``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe.
Database backends
^^^^^^^^^^^^^^^^^
* The MySQL backend no longer strips microseconds from ``datetime`` values as
MySQL 5.6.4 and up supports fractional seconds depending on the declaration
of the datetime field (when ``DATETIME`` includes fractional precision greater
than 0).
Email Email
^^^^^ ^^^^^