Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #20501 -- failure of datetime queries with timezones under Oracle

  • Loading branch information...
commit 5e05ec3ea60a367f97ebf1321f79bf929446f07d 1 parent 90af278
@shaib shaib authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 django/db/backends/oracle/base.py
View
7 django/db/backends/oracle/base.py
@@ -442,9 +442,10 @@ def year_lookup_bounds_for_datetime_field(self, value):
# 'second' instead -- cx_Oracle chops the fraction-of-second part
# off of datetime objects, leaving almost an entire second out of
# the year under the default implementation.
- first = '%s-01-01'
- second = '%s-12-31 23:59:59.999999'
- return [first % value, second % value]
+ bounds = super(DatabaseOperations, self).year_lookup_bounds_for_datetime_field(value)
+ if settings.USE_TZ:
+ bounds = [b.astimezone(timezone.utc).replace(tzinfo=None) for b in bounds]
+ return [b.isoformat(b' ') for b in bounds]
def combine_expression(self, connector, sub_expressions):
"Oracle requires special cases for %% and & operators in query expressions"
Please sign in to comment.
Something went wrong with that request. Please try again.