Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Corrected an edge case introduced in r12602. Thanks to Ramiro…

… Morales for the eagle eyes.

Backport of r12605 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12606 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 121188e254c41641f3ee16b767ef456e87feff7f 1 parent 9405460
Russell Keith-Magee authored February 26, 2010
7  django/db/backends/postgresql/base.py
@@ -97,9 +97,11 @@ def __init__(self, *args, **kwargs):
97 97
         self.validation = BaseDatabaseValidation()
98 98
 
99 99
     def _cursor(self):
  100
+        new_connection = False
100 101
         set_tz = False
101 102
         settings_dict = self.settings_dict
102 103
         if self.connection is None:
  104
+            new_connection = True
103 105
             set_tz = settings_dict.get('TIME_ZONE')
104 106
             if settings_dict['DATABASE_NAME'] == '':
105 107
                 from django.core.exceptions import ImproperlyConfigured
@@ -117,8 +119,9 @@ def _cursor(self):
117 119
             self.connection.set_isolation_level(1) # make transactions transparent to all cursors
118 120
             connection_created.send(sender=self.__class__)
119 121
         cursor = self.connection.cursor()
120  
-        if set_tz:
121  
-            cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
  122
+        if new_connection:
  123
+            if set_tz:
  124
+                cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
122 125
             if not hasattr(self, '_version'):
123 126
                 self.__class__._version = get_version(cursor)
124 127
             if self._version[0:2] < (8, 0):
7  django/db/backends/postgresql_psycopg2/base.py
@@ -74,9 +74,11 @@ def __init__(self, *args, **kwargs):
74 74
         self.validation = BaseDatabaseValidation()
75 75
 
76 76
     def _cursor(self):
  77
+        new_connection = False
77 78
         set_tz = False
78 79
         settings_dict = self.settings_dict
79 80
         if self.connection is None:
  81
+            new_connection = True
80 82
             set_tz = settings_dict.get('TIME_ZONE')
81 83
             if settings_dict['DATABASE_NAME'] == '':
82 84
                 from django.core.exceptions import ImproperlyConfigured
@@ -101,8 +103,9 @@ def _cursor(self):
101 103
             connection_created.send(sender=self.__class__)
102 104
         cursor = self.connection.cursor()
103 105
         cursor.tzinfo_factory = None
104  
-        if set_tz:
105  
-            cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
  106
+        if new_connection:
  107
+            if set_tz:
  108
+                cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
106 109
             if not hasattr(self, '_version'):
107 110
                 self.__class__._version = get_version(cursor)
108 111
             if self._version[0:2] < (8, 0):

0 notes on commit 121188e

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