Tuesday, April 24, 2012

transaction.commit_on_success committing prematurely?

I'm having some issues with commit_on_success.  It appears to be
committing prematurely, and I'm not quite sure why.

I have the following code:

@transaction.commit_on_success
def test():
s = Somemodel.objects.all()[0]
s.hostname = 'this_is_a_test'
s.save()
raise AttributeError('oh no')

>>> test()
AttributeError: oh no

This code produces these queries:
...
6 Query UPDATE somemodel` SET `hostname` = 'this_is_a_test' ...
6 Query commit


I don't understand why my update is being committed, is there
something I'm missing here?


My database is mysql, and my tables are InnoDB.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment