diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-26 16:12:54 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-26 16:12:54 +0000 |
| commit | 121188e254c41641f3ee16b767ef456e87feff7f (patch) | |
| tree | 00ab847e8905aa7709d9cae3b4f327e6f1dd0615 | |
| parent | 94054604e484f21c95b77fbbed81e5670900a653 (diff) | |
[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
| -rw-r--r-- | django/db/backends/postgresql/base.py | 7 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index f3c03c24ea..77f7c38a6f 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -97,9 +97,11 @@ class DatabaseWrapper(BaseDatabaseWrapper): self.validation = BaseDatabaseValidation() 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['DATABASE_NAME'] == '': from django.core.exceptions import ImproperlyConfigured @@ -117,8 +119,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): 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): diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index d381cf60b7..a859a77d7a 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -74,9 +74,11 @@ class DatabaseWrapper(BaseDatabaseWrapper): self.validation = BaseDatabaseValidation() 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['DATABASE_NAME'] == '': from django.core.exceptions import ImproperlyConfigured @@ -101,8 +103,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): 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): |
