#16549: In Django models, modified-rows count would help in handling optimistic
concurrency control problems
-------------------------------------+-------------------------------------
               Reporter:             |          Owner:  nobody
  estebistec                         |         Status:  new
                   Type:  New        |      Component:  Database layer
  feature                            |  (models, ORM)
              Milestone:             |       Severity:  Normal
                Version:  1.3        |       Keywords:
             Resolution:             |      Has patch:  0
           Triage Stage:  Design     |    Needs tests:  0
  decision needed                    |  Easy pickings:  0
    Needs documentation:  0          |
Patch needs improvement:  0          |
                  UI/UX:  0          |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 One can implement any logic in the signal callback. But it does take too
 much work to implement such a field. Also, relying on catching the
 exceptions from the save is just plain wrong (it results in transaction
 commit all too easily). The optimistic lock check should be done in model
 validation if possible.

 A conditional save would be handy. But it is not trivial to implement. The
 implementation should be one that handles derived classes, does not easily
 lead to half-updates (the condition was ok for the first table in derived
 save, but not for the second) and does not lead to too much code
 duplication. Having two different versions of base_save does not look
 appealing. Are there enough use cases that are not solvable by overriding
 the save() method or signals?

 It is a good idea to return models.UPDATED or models.INSERTED from save(),
 returning models.DELETED or models.NO_ACTION from delete() and modified
 object counts from qs.update(), qs.delete(). Row counts instead of object
 counts from qs.update() and qs.delete() is a bit harder problem. The
 object count would not include related models deleted or updated. The
 return values from save() and delete() are just examples.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16549#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to