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)
|
return "TIME(%s)" % (field_name)
|
||||||
|
|
||||||
def date_interval_sql(self, timedelta):
|
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):
|
def format_for_duration_arithmetic(self, sql):
|
||||||
if self.connection.features.supports_microsecond_precision:
|
if self.connection.features.supports_microsecond_precision:
|
||||||
|
|
|
@ -77,7 +77,7 @@ END;
|
||||||
"""
|
"""
|
||||||
NUMTODSINTERVAL converts number to INTERVAL DAY TO SECOND literal.
|
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):
|
def date_trunc_sql(self, lookup_type, field_name):
|
||||||
# https://docs.oracle.com/database/121/SQLRF/functions271.htm#SQLRF52058
|
# 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)
|
return "django_date_extract('%s', %s)" % (lookup_type.lower(), field_name)
|
||||||
|
|
||||||
def date_interval_sql(self, timedelta):
|
def date_interval_sql(self, timedelta):
|
||||||
return "'%s'" % duration_string(timedelta), []
|
return "'%s'" % duration_string(timedelta)
|
||||||
|
|
||||||
def format_for_duration_arithmetic(self, sql):
|
def format_for_duration_arithmetic(self, sql):
|
||||||
"""Do nothing since formatting is handled in the custom function."""
|
"""Do nothing since formatting is handled in the custom function."""
|
||||||
|
|
|
@ -639,7 +639,7 @@ class DurationValue(Value):
|
||||||
connection.ops.check_expression_support(self)
|
connection.ops.check_expression_support(self)
|
||||||
if connection.features.has_native_duration_field:
|
if connection.features.has_native_duration_field:
|
||||||
return super().as_sql(compiler, connection)
|
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):
|
class RawSQL(Expression):
|
||||||
|
|
|
@ -323,9 +323,10 @@ This section describes changes that may be needed in third-party database
|
||||||
backends.
|
backends.
|
||||||
|
|
||||||
* The ``DatabaseOperations.datetime_cast_date_sql()``,
|
* The ``DatabaseOperations.datetime_cast_date_sql()``,
|
||||||
``datetime_cast_time_sql()``, ``datetime_trunc_sql()``, and
|
``datetime_cast_time_sql()``, ``datetime_trunc_sql()``,
|
||||||
``datetime_extract_sql()`` methods now return only the SQL to perform the
|
``datetime_extract_sql()``, and ``date_interval_sql()`` methods now return
|
||||||
operation instead of SQL and a list of parameters.
|
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``
|
* Third-party database backends should add a ``DatabaseWrapper.display_name``
|
||||||
attribute with the name of the database that your backend works with. Django
|
attribute with the name of the database that your backend works with. Django
|
||||||
|
|
Loading…
Reference in New Issue