summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2014-04-11 22:55:07 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2014-04-25 22:45:11 +0200
commit3033a7193afcd1abdc0158e95ca3a241d8448d25 (patch)
treef9e0caa9a678be703dab7a5d74c0a29d333e07b3 /django
parent5c0333de2e08db6e47ad06e61b3214cf626d386d (diff)
Fixed #21166 -- Reset errors_occurred flag after commit and rollback.
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 96e249a079..d9f9bf1c07 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -166,6 +166,8 @@ class BaseDatabaseWrapper(object):
self.validate_thread_sharing()
self.validate_no_atomic_block()
self._commit()
+ # A successful commit means that the database connection works.
+ self.errors_occurred = False
def rollback(self):
"""
@@ -174,6 +176,8 @@ class BaseDatabaseWrapper(object):
self.validate_thread_sharing()
self.validate_no_atomic_block()
self._rollback()
+ # A successful rollback means that the database connection works.
+ self.errors_occurred = False
def close(self):
"""
@@ -381,6 +385,8 @@ class BaseDatabaseWrapper(object):
self.close()
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.is_usable():
self.errors_occurred = False