summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShai Berger <shai@platonix.com>2013-05-22 01:31:14 +0300
committerShai Berger <shai@platonix.com>2013-05-22 01:52:15 +0300
commitdfe6ea3b1f6c7119a552ba6a018f89745e767132 (patch)
treeead90b2908a1c2c8148f6e725cdcae06ae1bd751
parent8fd40b9ae783614658f6e0ca7af7f2faab0c48fc (diff)
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.
-rw-r--r--django/db/backends/oracle/base.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index f05c9091c9..dd89ae0ba8 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -436,6 +436,16 @@ WHEN (new.%(col_name)s IS NULL)
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 == '%%':