Hi list, #9964 is about managed transactions not being committed under transaction middleware (or transaction.commit_on_success decorator) after the database was modified via raw SQL. The root cause of that is that, today, managed transactions only become "dirty" when there is clear evidence of database change -- that is, when a known-to-change-the-database operation (such as saving a model) is performed. If this isn't the case (as in the case of raw SQL), the user is required to call transaction.set_dirty() to get correct behavior.
More generally, transactions which stay "clean" are not really closed by the transaction-management mechanism. If the transaction is part of a request, it will be implicitly rolled back at the end of the request when the connection is closed. If, under any circumstances, the connection stays open, so does the transaction; this is rare, but wrong, and a user will have no warning except for bugs creeping up. Yesterday I submitted a patch for this bug, which corrects this behavior by stipulating that every transaction where an operation was performed in managed mode should be considered dirty. In other words, there are no more "read-only transactions". Every (managed) transaction that is opened must be closed. This is a backward-incompatible change: most users, who either use automatic mode or some form of commit_on_success, should see no difference, but users working with commit_manually will be forced to close read-only transactions explicitly -- which they could get away with not doing before. I believe this leads to more correct code even in these cases, and all in all, it trades a silent gotcha in one situation for a clear exception in another: Under the current scheme, raw SQL execution can get rolled back silently if set_dirty() isn't called; while this is documented, it is a gotcha. Under my proposed fix, unclosed read-only transactions raise a TransactionManagementError. I think this is an overall improvement. But I also think more people would have an opinion about it, than those who follow http://code.djangoproject.com/ticket/9964. Your comments are welcome, Shai. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.