From 551c997feaaa293987af8b05efc3634b93305fac Mon Sep 17 00:00:00 2001 From: Manaia Junior Date: Fri, 22 Oct 2021 02:55:25 -0300 Subject: [PATCH] Fixed #33214 -- Added BaseDatabaseOperations.format_for_duration_arithmetic() stub method. --- django/db/backends/base/operations.py | 6 ++++++ tests/backends/base/test_operations.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py index f6a043e31f5..279297ac856 100644 --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -74,6 +74,12 @@ class BaseDatabaseOperations: """ return len(objs) + def format_for_duration_arithmetic(self, sql): + raise NotImplementedError( + 'subclasses of BaseDatabaseOperations may require a ' + 'format_for_duration_arithmetic() method.' + ) + def cache_key_culling_sql(self): """ Return an SQL query that retrieves the first cache key greater than the diff --git a/tests/backends/base/test_operations.py b/tests/backends/base/test_operations.py index 1cfea44e83d..b7b7b9e3fc2 100644 --- a/tests/backends/base/test_operations.py +++ b/tests/backends/base/test_operations.py @@ -85,6 +85,11 @@ class SimpleDatabaseOperationTests(SimpleTestCase): now = timezone.now() self.assertEqual(self.ops.adapt_timefield_value(now), str(now)) + def test_format_for_duration_arithmetic(self): + msg = self.may_require_msg % 'format_for_duration_arithmetic' + with self.assertRaisesMessage(NotImplementedError, msg): + self.ops.format_for_duration_arithmetic(None) + def test_date_extract_sql(self): with self.assertRaisesMessage(NotImplementedError, self.may_require_msg % 'date_extract_sql'): self.ops.date_extract_sql(None, None)