On Wed, 2014-10-01 at 14:31 +1000, Curtis Maloney wrote:
> This is primarily a function of the DBMS.  When your operations cause
> a DB-level error, the DB needs to roll back the transaction to clean
> up.

This depends on the database. On PostgreSQL, after any error the
transaction (or savepoint) must be rolled back. But on MySQL and Oracle
it is OK to continue the transaction. The PostgreSQL behavior is much
safer, and that is why Django defaults to that behavior.

There are query patterns where IntegrityError is expected - for example
try to insert, if IntegrityError, then update.

Django does allow to continue the transaction if you explicitly choose
to do so. After handling the error, you must use set_rollback[1]. This
is useful for those rare cases where you want to continue after error in
transaction.

 - Anssi

1. 
https://docs.djangoproject.com/en/dev/topics/db/transactions/#django.db.transaction.set_rollback
 


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/1412139940.14923.170.camel%40TTY32.
For more options, visit https://groups.google.com/d/optout.

Reply via email to