django-exclusivebooleanfield
django-exclusivebooleanfield copied to clipboard
Replaced save methods interferes with transaction management
The following simple example (Django 1.4) shows how the replaced save function of models with ExclusiveBooleanField can led to data saved in the database which were not meant to end up there:
def function():
with transaction.commit_on_succes():
# Part 1: does some stuff which changes database
instanceOfModelWithExclusiveBooleanField.save()
# Part 2: throws an exception
The with transaction.commit_on_succes() block is meant to group stuff which should end up all together or nothing of it in the database. A call of save to a model with ExclusiveBooleanField in the middle breaks this assumption because in the replaced save function commit_on_success is used which would commit the open transaction. In the example everything of Part 1 one will be in the database regardless if an exception is thrown in Part 2 or not.