Commit 746cded0 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

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

Refs #21202.

Backport of 3becac84 from master
parent 9afedbef
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -457,6 +457,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
            pass

    def _set_autocommit(self, autocommit):
        with self.wrap_database_errors:
            self.connection.autocommit(autocommit)

    def disable_constraint_checking(self):
+2 −1
Original line number Diff line number Diff line
@@ -625,6 +625,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
        pass

    def _set_autocommit(self, autocommit):
        with self.wrap_database_errors:
            self.connection.autocommit = autocommit

    def check_constraints(self, table_names=None):
+8 −7
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
            self.connection.set_isolation_level(isolation_level)

    def _set_autocommit(self, autocommit):
        with self.wrap_database_errors:
            if self.psycopg2_version >= (2, 4, 2):
                self.connection.autocommit = autocommit
            else:
+2 −1
Original line number Diff line number Diff line
@@ -387,6 +387,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
            level = ''
        # 'isolation_level' is a misleading API.
        # SQLite always runs at the SERIALIZABLE isolation level.
        with self.wrap_database_errors:
            self.connection.isolation_level = level

    def check_constraints(self, table_names=None):