Commit 713f2349 authored by Claude Paroz's avatar Claude Paroz
Browse files

Required MySQLdb >= 1.2.5 for fractional seconds support

On MySQLdb < 1.2.5, MySQLdb returns None when fetching datetime/time
values with fractional seconds.
See https://github.com/farcepest/MySQLdb1/issues/24
parent 22da5f88
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -211,7 +211,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):

    @cached_property
    def supports_microsecond_precision(self):
        return self.connection.mysql_version >= (5, 6, 4)
        # 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):
+7 −2
Original line number Diff line number Diff line
@@ -503,7 +503,11 @@ Fractional seconds support for Time and DateTime fields

MySQL 5.6.4 and later can store fractional seconds, provided that the
column definition includes a fractional indication (e.g. ``DATETIME(6)``).
Earlier versions do not support them at all.
Earlier versions do not support them at all. In addition, versions of MySQLdb
older than 1.2.5 have `a bug`_ that also prevents the use of fractional seconds
with MySQL.

.. _a bug: https://github.com/farcepest/MySQLdb1/issues/24

Django will not upgrade existing columns to include fractional seconds if the
database server supports it. If you want to enable them on an existing database,
@@ -521,7 +525,8 @@ or using a :class:`~django.db.migrations.operations.RunSQL` operation in a
    ``time`` values when using the MySQL backend. Now it lets the database
    decide whether it should drop that part of the value or not. By default, new
    ``DateTimeField`` or ``TimeField`` columns are now created with fractional
    seconds support on MySQL 5.6.4 or later.
    seconds support on MySQL 5.6.4 or later with either mysqlclient or
    MySQLdb 1.2.5 or later.

``TIMESTAMP`` columns
~~~~~~~~~~~~~~~~~~~~~