summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-08-24 14:56:09 -0400
committerTim Graham <timograham@gmail.com>2017-09-25 14:48:11 -0400
commit8a1768432b1ec3ecfa390ac5eb70dbfb0cff59b3 (patch)
tree47c842a0a041a0865de859cf7d333cef3250a897 /django/db
parent6da140724dba546d2f3aced1308e617747b0385c (diff)
Fixed #28552 -- Dropped support for MySQL 5.5.
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/mysql/base.py13
-rw-r--r--django/db/backends/mysql/features.py4
-rw-r--r--django/db/backends/mysql/operations.py26
3 files changed, 9 insertions, 34 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 0e5c25fc23..1eb3677b80 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -97,14 +97,14 @@ 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',
'BigAutoField': 'bigint AUTO_INCREMENT',
'BinaryField': 'longblob',
'BooleanField': 'bool',
'CharField': 'varchar(%(max_length)s)',
'DateField': 'date',
- 'DateTimeField': 'datetime',
+ 'DateTimeField': 'datetime(6)',
'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
'DurationField': 'bigint',
'FileField': 'varchar(%(max_length)s)',
@@ -121,17 +121,10 @@ class DatabaseWrapper(BaseDatabaseWrapper):
'SlugField': 'varchar(%(max_length)s)',
'SmallIntegerField': 'smallint',
'TextField': 'longtext',
- 'TimeField': 'time',
+ 'TimeField': 'time(6)',
'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
-
# For these columns, MySQL doesn't:
# - accept default values and implicitly treats these columns as nullable
# - support a database index
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py
index 18ab088941..542b621aa9 100644
--- a/django/db/backends/mysql/features.py
+++ b/django/db/backends/mysql/features.py
@@ -61,10 +61,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
return self._mysql_storage_engine != 'MyISAM'
@cached_property
- def supports_microsecond_precision(self):
- return self.connection.mysql_version >= (5, 6, 4)
-
- @cached_property
def has_zoneinfo_database(self):
# Test if the time zone definitions are installed.
with self.connection.cursor() as cursor:
diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
index e4492f866f..474cd8d467 100644
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -109,10 +109,7 @@ class DatabaseOperations(BaseDatabaseOperations):
return "INTERVAL '%06f' SECOND_MICROSECOND" % timedelta.total_seconds()
def format_for_duration_arithmetic(self, sql):
- if self.connection.features.supports_microsecond_precision:
- return 'INTERVAL %s MICROSECOND' % sql
- else:
- return 'INTERVAL FLOOR(%s / 1000000) SECOND' % sql
+ return 'INTERVAL %s MICROSECOND' % sql
def force_no_ordering(self):
"""
@@ -178,10 +175,6 @@ class DatabaseOperations(BaseDatabaseOperations):
value = timezone.make_naive(value, self.connection.timezone)
else:
raise ValueError("MySQL backend does not support timezone-aware datetimes when USE_TZ is False.")
-
- if not self.connection.features.supports_microsecond_precision:
- value = value.replace(microsecond=0)
-
return str(value)
def adapt_timefield_value(self, value):
@@ -258,17 +251,10 @@ class DatabaseOperations(BaseDatabaseOperations):
def subtract_temporals(self, internal_type, lhs, rhs):
lhs_sql, lhs_params = lhs
rhs_sql, rhs_params = rhs
- if self.connection.features.supports_microsecond_precision:
- if internal_type == 'TimeField':
- return (
- "((TIME_TO_SEC(%(lhs)s) * POW(10, 6) + MICROSECOND(%(lhs)s)) -"
- " (TIME_TO_SEC(%(rhs)s) * POW(10, 6) + MICROSECOND(%(rhs)s)))"
- ) % {'lhs': lhs_sql, 'rhs': rhs_sql}, lhs_params * 2 + rhs_params * 2
- else:
- return "TIMESTAMPDIFF(MICROSECOND, %s, %s)" % (rhs_sql, lhs_sql), rhs_params + lhs_params
- elif internal_type == 'TimeField':
+ if internal_type == 'TimeField':
return (
- "(TIME_TO_SEC(%s) * POW(10, 6) - TIME_TO_SEC(%s) * POW(10, 6))"
- ) % (lhs_sql, rhs_sql), lhs_params + rhs_params
+ "((TIME_TO_SEC(%(lhs)s) * POW(10, 6) + MICROSECOND(%(lhs)s)) -"
+ " (TIME_TO_SEC(%(rhs)s) * POW(10, 6) + MICROSECOND(%(rhs)s)))"
+ ) % {'lhs': lhs_sql, 'rhs': rhs_sql}, lhs_params * 2 + rhs_params * 2
else:
- return "(TIMESTAMPDIFF(SECOND, %s, %s) * POW(10, 6))" % (rhs_sql, lhs_sql), rhs_params + lhs_params
+ return "TIMESTAMPDIFF(MICROSECOND, %s, %s)" % (rhs_sql, lhs_sql), rhs_params + lhs_params