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
This commit is contained in:
Claude Paroz 2014-10-11 14:47:54 +02:00
parent 22da5f8817
commit 713f23492a
2 changed files with 10 additions and 3 deletions

View File

@ -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):

View File

@ -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
~~~~~~~~~~~~~~~~~~~~~