summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql_psycopg2/base.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-01-12 20:27:08 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-01-12 20:31:07 +0100
commitfbe1abac4af3a7fc138bd176471e36acb1070a58 (patch)
tree10c799bcf5be0f12b2fa4d97eb0efe11ef3b6480 /django/db/backends/postgresql_psycopg2/base.py
parentc726598c3da5320df88a10fc407f8df6874589b1 (diff)
Fixed #21453 -- Enabled autocommit before calling init_connection_state.
Also ensured the transaction state is clean on Oracle while I was there. This change cannot be backported to 1.6 because it's backwards-incompatible for custom database backends.
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index c7fd98ae98..7725b0c7a0 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -142,12 +142,12 @@ class DatabaseWrapper(BaseDatabaseWrapper):
conn_tz = get_parameter_status('TimeZone')
if conn_tz != tz:
- self.connection.cursor().execute(
- self.ops.set_time_zone_sql(), [tz]
- )
+ cursor = self.connection.cursor()
+ cursor.execute(self.ops.set_time_zone_sql(), [tz])
+ cursor.close()
# Commit after setting the time zone (see #17062)
- self.connection.commit()
- self.connection.set_isolation_level(self.isolation_level)
+ if not self.get_autocommit():
+ self.connection.commit()
def create_cursor(self):
cursor = self.connection.cursor()