Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrected an edge case introduced in r12602. Thanks to Ramiro Morales…

… for the eagle eyes.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12605 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5670331343f7a31c7c9f4d15b8ccb09efb15a920 1 parent 46cc702
@freakboy3742 freakboy3742 authored
View
7 django/db/backends/postgresql/base.py
@@ -116,9 +116,11 @@ def __init__(self, *args, **kwargs):
self.validation = BaseDatabaseValidation(self)
def _cursor(self):
+ new_connection = False
set_tz = False
settings_dict = self.settings_dict
if self.connection is None:
+ new_connection = True
set_tz = settings_dict.get('TIME_ZONE')
if settings_dict['NAME'] == '':
from django.core.exceptions import ImproperlyConfigured
@@ -136,8 +138,9 @@ def _cursor(self):
self.connection.set_isolation_level(1) # make transactions transparent to all cursors
connection_created.send(sender=self.__class__)
cursor = self.connection.cursor()
- if set_tz:
- cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
+ if new_connection:
+ if set_tz:
+ cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
if not hasattr(self, '_version'):
self.__class__._version = get_version(cursor)
if self._version[0:2] < (8, 0):
View
7 django/db/backends/postgresql_psycopg2/base.py
@@ -110,9 +110,11 @@ def __init__(self, *args, **kwargs):
self.validation = BaseDatabaseValidation(self)
def _cursor(self):
+ new_connection = False
set_tz = False
settings_dict = self.settings_dict
if self.connection is None:
+ new_connection = True
set_tz = settings_dict.get('TIME_ZONE')
if settings_dict['NAME'] == '':
from django.core.exceptions import ImproperlyConfigured
@@ -137,8 +139,9 @@ def _cursor(self):
connection_created.send(sender=self.__class__)
cursor = self.connection.cursor()
cursor.tzinfo_factory = None
- if set_tz:
- cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
+ if new_connection:
+ if set_tz:
+ cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
if not hasattr(self, '_version'):
self.__class__._version = get_version(cursor)
if self._version[0:2] < (8, 0):
Please sign in to comment.
Something went wrong with that request. Please try again.