Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Simplified time zone support in the Oracle backend. Avoided outputtyp…

…ehandler 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
  • Loading branch information...
commit 2693aa890ea6c8273dcdaeab6101203f37ffb1f3 1 parent 5f9dbef
Aymeric Augustin authored December 07, 2011

Showing 1 changed file with 6 additions and 18 deletions. Show diff stats Hide diff stats

  1. 24  django/db/backends/oracle/base.py
24  django/db/backends/oracle/base.py
@@ -485,24 +485,6 @@ def _cursor(self):
485 485
                            " NLS_TERRITORY = 'AMERICA'"
486 486
                            + (" TIME_ZONE = 'UTC'" if settings.USE_TZ else ''))
487 487
 
488  
-            def datetime_converter(dt):
489  
-                # Confirm that dt is naive before overwriting its tzinfo.
490  
-                if dt is not None and is_naive(dt):
491  
-                    dt = dt.replace(tzinfo=utc)
492  
-                return dt
493  
-
494  
-            def output_type_handler(cursor, name, default_type,
495  
-                                    size, precision, scale):
496  
-                # datetimes are returned as TIMESTAMP, except the results
497  
-                # of "dates" queries, which are returned as DATETIME.
498  
-                if settings.USE_TZ and default_type in (Database.TIMESTAMP,
499  
-                                                        Database.DATETIME):
500  
-                    return cursor.var(default_type,
501  
-                                      arraysize=cursor.arraysize,
502  
-                                      outconverter=datetime_converter)
503  
-
504  
-            self.connection.outputtypehandler = output_type_handler
505  
-
506 488
             if 'operators' not in self.__dict__:
507 489
                 # Ticket #14149: Check whether our LIKE implementation will
508 490
                 # work for this connection or we need to fall back on LIKEC.
@@ -794,6 +776,12 @@ def _rowfactory(row, cursor):
794 776
                 value = decimal.Decimal(value)
795 777
             else:
796 778
                 value = int(value)
  779
+        # datetimes are returned as TIMESTAMP, except the results
  780
+        # of "dates" queries, which are returned as DATETIME.
  781
+        elif desc[1] in (Database.TIMESTAMP, Database.DATETIME):
  782
+            # Confirm that dt is naive before overwriting its tzinfo.
  783
+            if settings.USE_TZ and value is not None and is_naive(value):
  784
+                value = value.replace(tzinfo=utc)
797 785
         elif desc[1] in (Database.STRING, Database.FIXED_CHAR,
798 786
                          Database.LONG_STRING):
799 787
             value = to_unicode(value)

0 notes on commit 2693aa8

Please sign in to comment.
Something went wrong with that request. Please try again.