summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2011-12-07 08:43:30 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2011-12-07 08:43:30 +0000
commit2693aa890ea6c8273dcdaeab6101203f37ffb1f3 (patch)
tree3f18fecc610cab0a93c193643078880215b7a47e
parent5f9dbef4bb5d8b9f077cd6a01b5e554f6dfb4f19 (diff)
Simplified time zone support in the Oracle backend. Avoided outputtypehandler which doesn't exist in cx_Oracle < 4.4.1.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/oracle/base.py24
1 files changed, 6 insertions, 18 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index c1974225f6..105730c69c 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -485,24 +485,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
" NLS_TERRITORY = 'AMERICA'"
+ (" TIME_ZONE = 'UTC'" if settings.USE_TZ else ''))
- def datetime_converter(dt):
- # Confirm that dt is naive before overwriting its tzinfo.
- if dt is not None and is_naive(dt):
- dt = dt.replace(tzinfo=utc)
- return dt
-
- def output_type_handler(cursor, name, default_type,
- size, precision, scale):
- # datetimes are returned as TIMESTAMP, except the results
- # of "dates" queries, which are returned as DATETIME.
- if settings.USE_TZ and default_type in (Database.TIMESTAMP,
- Database.DATETIME):
- return cursor.var(default_type,
- arraysize=cursor.arraysize,
- outconverter=datetime_converter)
-
- self.connection.outputtypehandler = output_type_handler
-
if 'operators' not in self.__dict__:
# Ticket #14149: Check whether our LIKE implementation will
# work for this connection or we need to fall back on LIKEC.
@@ -794,6 +776,12 @@ def _rowfactory(row, cursor):
value = decimal.Decimal(value)
else:
value = int(value)
+ # datetimes are returned as TIMESTAMP, except the results
+ # of "dates" queries, which are returned as DATETIME.
+ elif desc[1] in (Database.TIMESTAMP, Database.DATETIME):
+ # Confirm that dt is naive before overwriting its tzinfo.
+ if settings.USE_TZ and value is not None and is_naive(value):
+ value = value.replace(tzinfo=utc)
elif desc[1] in (Database.STRING, Database.FIXED_CHAR,
Database.LONG_STRING):
value = to_unicode(value)