diff options
| author | Shai Berger <shai@platonix.com> | 2013-05-27 16:48:28 +0300 |
|---|---|---|
| committer | Shai Berger <shai@platonix.com> | 2013-05-27 17:28:57 +0300 |
| commit | 5e05ec3ea60a367f97ebf1321f79bf929446f07d (patch) | |
| tree | 0db0fb5f813e27194637d58f9b983e168d81ee62 | |
| parent | 90af278203963e3e3f96e443971cd38a2dad34e4 (diff) | |
Fixed #20501 -- failure of datetime queries with timezones under Oracle
| -rw-r--r-- | django/db/backends/oracle/base.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index dd89ae0ba8..0afc5f23e8 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -442,9 +442,10 @@ WHEN (new.%(col_name)s IS NULL) # '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" |
