summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/operations.py
diff options
context:
space:
mode:
authorVytis Banaitis <vytis.banaitis@gmail.com>2017-02-17 20:34:22 +0200
committerTim Graham <timograham@gmail.com>2017-02-21 12:06:16 -0500
commit4045fd56cb0f83d0f78de9aca073c7104e4cf8fd (patch)
treeb2e72f157a082b91a728dc48297f93d00cb2e2e3 /django/db/backends/postgresql/operations.py
parent5a6f70b4281817656db2f36c5919036d38fcce7f (diff)
downloaddjango-4045fd56cb0f83d0f78de9aca073c7104e4cf8fd.tar.gz
Fixed #27856 -- Improved accuracy of date subtraction on PostgreSQL.
Accuracy was incorrect when dates differ by a month or more.
Diffstat (limited to 'django/db/backends/postgresql/operations.py')
-rw-r--r--django/db/backends/postgresql/operations.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
index 8891612074..463fdc3eda 100644
--- a/django/db/backends/postgresql/operations.py
+++ b/django/db/backends/postgresql/operations.py
@@ -253,7 +253,7 @@ class DatabaseOperations(BaseDatabaseOperations):
if internal_type == 'DateField':
lhs_sql, lhs_params = lhs
rhs_sql, rhs_params = rhs
- return "age(%s, %s)" % (lhs_sql, rhs_sql), lhs_params + rhs_params
+ return "(interval '1 day' * (%s - %s))" % (lhs_sql, rhs_sql), lhs_params + rhs_params
return super().subtract_temporals(internal_type, lhs, rhs)
def fulltext_search_sql(self, field_name):