From df1106a40ff0cb8946e36e96edb1da6301e0eacd Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 6 Jul 2017 13:37:47 +0200 Subject: [PATCH] Fixed #28365 -- Unified DatabaseOperations.date_interval_sql() return value with similar methods. --- django/db/backends/mysql/operations.py | 2 +- django/db/backends/oracle/operations.py | 2 +- django/db/backends/sqlite3/operations.py | 2 +- django/db/models/expressions.py | 2 +- docs/releases/2.0.txt | 7 ++++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py index 584eb56e705..e7fc2b93bfd 100644 --- a/django/db/backends/mysql/operations.py +++ b/django/db/backends/mysql/operations.py @@ -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: diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index 17c3d93a5cf..09c0e18d844 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -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 diff --git a/django/db/backends/sqlite3/operations.py b/django/db/backends/sqlite3/operations.py index 5ffc65e08a6..f030c9ed999 100644 --- a/django/db/backends/sqlite3/operations.py +++ b/django/db/backends/sqlite3/operations.py @@ -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.""" diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index e42555ed80b..5cd558c12ae 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -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): diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 8dfc43c24d9..3985f158fdf 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -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