On 21 sept. 2013, at 15:53, Richard Ward <[email protected]> wrote:
> I'm OK with trying to to raise exceptions when making a query and > get_rollback returns True. I'm not sure it's doable; patch welcome ;-) > > How about this: > https://github.com/RichardOfWard/django/commit/cb46c75db275db59b54511c090286255bd9cc46d > > It raises the same error that PostgreSQL would raise if you try and do any > SQL when in a transaction with 'needs_rollback' is True. I've tested this > with PostgreSQL, MySQL and SQLite3, and they all now behave in the same way > that PostgreSQL behave currently (I'm running the test suite at the moment, > its taking a while). I wrote a patch based on this idea and unfortunately it doesn't work: https://code.djangoproject.com/attachment/ticket/21134/21134-failed-attempt.patch This patch triggers a large number of failures in the tests, because it prevents some read queries which are currently allowed. You didn't notice because your patch only works when DEBUG = True and the test suite runs with DEBUG = False. If we step back from the implementation, the issue here is that MySQL and Oracle implicitly add a savepoint before each query, and under some circumstances implicitly rollback to that savepoint. This behavior allows transaction management schemes that don't map well to a context manager / decorator API like Django's. See also https://code.djangoproject.com/ticket/11156#comment:14 which has the same root cause. I made a significant effort trying to implement the suggestions in this thread and didn't obtain any results. If someone still wants to change something in this area, please write a patch with tests; I will review it. -- Aymeric. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.
