mirror of https://github.com/django/django.git
[1.6.x] Fixed #22321 -- Wrapped exceptions in _set_autocommit.
Refs #21202.
Backport of 3becac84
from master
This commit is contained in:
parent
9afedbef42
commit
746cded010
|
@ -457,7 +457,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
pass
|
||||
|
||||
def _set_autocommit(self, autocommit):
|
||||
self.connection.autocommit(autocommit)
|
||||
with self.wrap_database_errors:
|
||||
self.connection.autocommit(autocommit)
|
||||
|
||||
def disable_constraint_checking(self):
|
||||
"""
|
||||
|
|
|
@ -625,7 +625,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
pass
|
||||
|
||||
def _set_autocommit(self, autocommit):
|
||||
self.connection.autocommit = autocommit
|
||||
with self.wrap_database_errors:
|
||||
self.connection.autocommit = autocommit
|
||||
|
||||
def check_constraints(self, table_names=None):
|
||||
"""
|
||||
|
|
|
@ -169,14 +169,15 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
self.connection.set_isolation_level(isolation_level)
|
||||
|
||||
def _set_autocommit(self, autocommit):
|
||||
if self.psycopg2_version >= (2, 4, 2):
|
||||
self.connection.autocommit = autocommit
|
||||
else:
|
||||
if autocommit:
|
||||
level = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT
|
||||
with self.wrap_database_errors:
|
||||
if self.psycopg2_version >= (2, 4, 2):
|
||||
self.connection.autocommit = autocommit
|
||||
else:
|
||||
level = self.isolation_level
|
||||
self.connection.set_isolation_level(level)
|
||||
if autocommit:
|
||||
level = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT
|
||||
else:
|
||||
level = self.isolation_level
|
||||
self.connection.set_isolation_level(level)
|
||||
|
||||
def check_constraints(self, table_names=None):
|
||||
"""
|
||||
|
|
|
@ -387,7 +387,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
level = ''
|
||||
# 'isolation_level' is a misleading API.
|
||||
# SQLite always runs at the SERIALIZABLE isolation level.
|
||||
self.connection.isolation_level = level
|
||||
with self.wrap_database_errors:
|
||||
self.connection.isolation_level = level
|
||||
|
||||
def check_constraints(self, table_names=None):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue