Changes between Initial Version and Version 1 of Ticket #31640, comment 1


Ignore:
Timestamp:
May 29, 2020, 12:10:38 PM (4 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31640, comment 1

    initial v1  
    55{{{#!diff
    66diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
    7 index c67062a4a7..3877a38b43 100644
     7index c67062a4a7..c63e4dc8c0 100644
    88--- a/django/db/backends/postgresql/operations.py
    99+++ b/django/db/backends/postgresql/operations.py
     
    2828         return field_name
    2929
    30 @@ -71,7 +67,16 @@ class DatabaseOperations(BaseDatabaseOperations):
     30@@ -71,7 +67,14 @@ class DatabaseOperations(BaseDatabaseOperations):
    3131         # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
    3232         return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
     
    3434-    def time_trunc_sql(self, lookup_type, field_name):
    3535+    def date_trunc_sql(self, lookup_type, field_name, tzname=None):
    36 +        if tzname:
    37 +            field_name = self._convert_field_to_tz(field_name, tzname)
     36+        field_name = self._convert_field_to_tz(field_name, tzname)
    3837+        # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
    3938+        return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
    4039+
    4140+    def time_trunc_sql(self, lookup_type, field_name, tzname=None):
    42 +        if tzname:
    43 +            field_name = self._convert_field_to_tz(field_name, tzname)
     41+        field_name = self._convert_field_to_tz(field_name, tzname)
    4442+        field_name = self._convert_field_to_tz(field_name, tzname)
    4543         return "DATE_TRUNC('%s', %s)::time" % (lookup_type, field_name)
Back to Top