[1.7.x] Fixed #21166 -- Reset errors_occurred flag after commit and rollback.

Backport of 3033a71 from master.

Conflicts:
	django/db/backends/__init__.py
This commit is contained in:
Aymeric Augustin 2014-04-11 22:55:07 +02:00
parent 788fce4c91
commit 6b38e48ba1
1 changed files with 6 additions and 0 deletions

View File

@ -170,6 +170,8 @@ class BaseDatabaseWrapper(object):
self.validate_no_atomic_block() self.validate_no_atomic_block()
self._commit() self._commit()
self.set_clean() self.set_clean()
# A successful commit means that the database connection works.
self.errors_occurred = False
def rollback(self): def rollback(self):
""" """
@ -179,6 +181,8 @@ class BaseDatabaseWrapper(object):
self.validate_no_atomic_block() self.validate_no_atomic_block()
self._rollback() self._rollback()
self.set_clean() self.set_clean()
# A successful rollback means that the database connection works.
self.errors_occurred = False
def close(self): def close(self):
""" """
@ -475,6 +479,8 @@ class BaseDatabaseWrapper(object):
self.close() self.close()
return return
# If an exception other than DataError or IntegrityError occurred
# since the last commit / rollback, check if the connection works.
if self.errors_occurred: if self.errors_occurred:
if self.is_usable(): if self.is_usable():
self.errors_occurred = False self.errors_occurred = False