Fixed #28365 -- Unified DatabaseOperations.date_interval_sql() return value with similar methods.

This commit is contained in:
Mariusz Felisiak 2017-07-06 13:37:47 +02:00 committed by Tim Graham
parent 6de2930078
commit df1106a40f
5 changed files with 8 additions and 7 deletions

View File

@ -96,7 +96,7 @@ class DatabaseOperations(BaseDatabaseOperations):
return "TIME(%s)" % (field_name)
def date_interval_sql(self, timedelta):
return "INTERVAL '%06f' SECOND_MICROSECOND" % (timedelta.total_seconds()), []
return "INTERVAL '%06f' SECOND_MICROSECOND" % timedelta.total_seconds()
def format_for_duration_arithmetic(self, sql):
if self.connection.features.supports_microsecond_precision:

View File

@ -77,7 +77,7 @@ END;
"""
NUMTODSINTERVAL converts number to INTERVAL DAY TO SECOND literal.
"""
return "NUMTODSINTERVAL(%06f, 'SECOND')" % (timedelta.total_seconds()), []
return "NUMTODSINTERVAL(%06f, 'SECOND')" % timedelta.total_seconds()
def date_trunc_sql(self, lookup_type, field_name):
# https://docs.oracle.com/database/121/SQLRF/functions271.htm#SQLRF52058

View File

@ -54,7 +54,7 @@ class DatabaseOperations(BaseDatabaseOperations):
return "django_date_extract('%s', %s)" % (lookup_type.lower(), field_name)
def date_interval_sql(self, timedelta):
return "'%s'" % duration_string(timedelta), []
return "'%s'" % duration_string(timedelta)
def format_for_duration_arithmetic(self, sql):
"""Do nothing since formatting is handled in the custom function."""

View File

@ -639,7 +639,7 @@ class DurationValue(Value):
connection.ops.check_expression_support(self)
if connection.features.has_native_duration_field:
return super().as_sql(compiler, connection)
return connection.ops.date_interval_sql(self.value)
return connection.ops.date_interval_sql(self.value), []
class RawSQL(Expression):

View File

@ -323,9 +323,10 @@ This section describes changes that may be needed in third-party database
backends.
* The ``DatabaseOperations.datetime_cast_date_sql()``,
``datetime_cast_time_sql()``, ``datetime_trunc_sql()``, and
``datetime_extract_sql()`` methods now return only the SQL to perform the
operation instead of SQL and a list of parameters.
``datetime_cast_time_sql()``, ``datetime_trunc_sql()``,
``datetime_extract_sql()``, and ``date_interval_sql()`` methods now return
only the SQL to perform the operation instead of SQL and a list of
parameters.
* Third-party database backends should add a ``DatabaseWrapper.display_name``
attribute with the name of the database that your backend works with. Django