Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #20012 -- test_year_lookup_edge_case fails under Oracle

Used formatted date instead of datetime object for the end of the
year range, as the datetime object loses fractions-of-seconds when
inserted into the db.
  • Loading branch information...
commit dfe6ea3b1f6c7119a552ba6a018f89745e767132 1 parent 8fd40b9
@shaib shaib authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 django/db/backends/oracle/base.py
View
10 django/db/backends/oracle/base.py
@@ -436,6 +436,16 @@ def year_lookup_bounds_for_date_field(self, value):
second = '%s-12-31'
return [first % value, second % value]
+ def year_lookup_bounds_for_datetime_field(self, value):
+ # The default implementation uses datetime objects for the bounds.
+ # This must be overridden here, to use a formatted date (string) as
+ # '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]
+
def combine_expression(self, connector, sub_expressions):
"Oracle requires special cases for %% and & operators in query expressions"
if connector == '%%':
Please sign in to comment.
Something went wrong with that request. Please try again.