vendredi 13 février 2015

Django rollback an sqlite IntegrityError

I'm seeing occasional IntegrityErrors in one of our apps and to try and understand my options better I looked into writing tests for situation.



def test_deployment_feedback_integrity_error(self):
td = Deployment(environment=self.environment,
service=self.service,
requested_by=self.user).save()
testInstance = DeploymentFeedback()
testInstance.deployment = td
testInstance.save()

sid = transaction.savepoint()
self.assertRaises(IntegrityError, lambda: DeploymentFeedback.objects.create(deployment=td, pk=testInstance.pk))
transaction.rollback() # Fix above IntegrityError


transaction.rollback() doesn't fail, but also doesn't seem to do anything as subsequent requests to the DB fail within that test.


I've seen some talk online that SQLite doesn't support transaction rollback. Am I doing something wrong or is this correct?


Aucun commentaire:

Enregistrer un commentaire