I just created a new ticket (
https://code.djangoproject.com/ticket/20988), and marked it as release blocker for 1.6.
The summary of the issue is that there are some cases where the new save() algorithm will not save existing objects (for details about the algorithm, see #20988). This happens when an UPDATE of an existing row returns zero matched rows. At least PostgreSQL ON UPDATE triggers returning NULL can cause this condition. If an user is hit by this issue, then currently the options are to remove the trigger, or to use raw SQL for update of existing objects. There might be 3rd party backends or other conditions where the only option is raw SQL.
It would be nice to have better alternatives than raw SQL. Some options:
- Change back to old algorithm.
- Change the Model._do_update() to include forced_update flag. If this is done, it will be possible to override to _do_update() to use the old style algorithm. Unfortunately _do_update() is private API, but using that is likely better for most users than raw SQL.
- Add a select_on_save flag now, that is before release. The flag effectively forces use of the old algorithm. The implementation is straightforward, see
https://github.com/akaariai/django/commit/1ca398b0352b11868ec236f92cf17b6ce82ff88c. Docs missing, but otherwise ready.
- Wait and see. If there are enough complaints, add select_on_save or some other workaround later on (that is, mid 1.6, or in 1.7).
In addition, better release notes about this issue are needed.
I think reverting to the old algorithm isn't a good option. The new algorithm will save one query in most cases. I will do the _do_update() signature change now, it is good for those who want to use that particular private API in any case.
The real question is should something be done about select_on_save flag now?
- Anssi