mirror of https://github.com/django/django.git
Fixed #28365 -- Unified DatabaseOperations.date_interval_sql() return value with similar methods.
This commit is contained in:
parent
6de2930078
commit
df1106a40f
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue