Ticket #19716: 19716-1.diff

File 19716-1.diff, 1.7 KB (added by claudep, 12 months ago)

Stop stripping microseconds

  • django/db/backends/mysql/base.py

    diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
    index 61a8ab7..680c299 100644
    a b class DatabaseOperations(BaseDatabaseOperations): 
    371371            else:
    372372                raise ValueError("MySQL backend does not support timezone-aware datetimes when USE_TZ is False.")
    373373
    374         # MySQL doesn't support microseconds
    375         return six.text_type(value.replace(microsecond=0))
     374        return six.text_type(value)
    376375
    377376    def value_to_db_time(self, value):
    378377        if value is None:
    class DatabaseOperations(BaseDatabaseOperations): 
    382381        if timezone.is_aware(value):
    383382            raise ValueError("MySQL backend does not support timezone-aware times.")
    384383
    385         # MySQL doesn't support microseconds
    386         return six.text_type(value.replace(microsecond=0))
    387 
    388     def year_lookup_bounds_for_datetime_field(self, value):
    389         # Again, no microseconds
    390         first, second = super(DatabaseOperations, self).year_lookup_bounds_for_datetime_field(value)
    391         return [first.replace(microsecond=0), second.replace(microsecond=0)]
     384        return six.text_type(value)
    392385
    393386    def max_name_length(self):
    394387        return 64
  • docs/releases/1.8.txt

    diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
    index 789c1db..4ad9bac 100644
    a b Cache 
    8888
    8989* ...
    9090
     91Database backends
     92^^^^^^^^^^^^^^^^^
     93
     94* When Django saves ``datetime`` values through the MySQL backend, it does no
     95  longer strip microseconds, letting the database decide if it will discard
     96  them or not (MySQL 5.6.4 and up supports fractional seconds depending on the
     97  declaration of the datetime field).
     98
    9199Email
    92100^^^^^
    93101
Back to Top