Permalink
Browse files

[1.7.x] Fixed #22321 -- Wrapped exceptions in _set_autocommit.

Refs #21202.

Backport of 3becac8 from master
  • Loading branch information...
1 parent 7e89434 commit 5f22bda3827f32289793b90a387d8c77d602a859 @aaugustin aaugustin committed Mar 23, 2014
@@ -488,7 +488,8 @@ def _rollback(self):
pass
def _set_autocommit(self, autocommit):
- self.connection.autocommit(autocommit)
+ with self.wrap_database_errors:
+ self.connection.autocommit(autocommit)
def disable_constraint_checking(self):
"""
@@ -687,7 +687,8 @@ def _savepoint_commit(self, sid):
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):
"""
@@ -192,14 +192,15 @@ def _set_isolation_level(self, isolation_level):
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):
"""
@@ -411,7 +411,8 @@ def _set_autocommit(self, autocommit):
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):
"""

0 comments on commit 5f22bda

Please sign in to comment.