Skip to content

Commit

Permalink
Fixed #21166 -- Reset errors_occurred flag after commit and rollback.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Apr 25, 2014
1 parent 5c0333d commit 3033a71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django/db/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def commit(self):
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):
"""
Expand All @@ -174,6 +176,8 @@ def rollback(self):
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):
"""
Expand Down Expand Up @@ -381,6 +385,8 @@ def close_if_unusable_or_obsolete(self):
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
Expand Down

0 comments on commit 3033a71

Please sign in to comment.