#17332: Doing a save after primary key has changed should raise an error
----------------------------------------------+--------------------
     Reporter:  akaariai                      |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 Currently, if you change primary key and do a save(), you will get a
 duplicate in the database. In effect, the current behavior of save is:
 "save the object to DB, except when PK has changed, then do a clone". This
 API is not good for natural primary keys. Natural primary keys aren't that
 common currently, but if multicolumn primary keys are introduced into
 Django, they will be more common.

 The idea is to deprecate the current clone behavior of save raise an error
 instead. This would need to go through the normal deprecation cycle. You
 can get the current behavior back by using .save(clone=True). For
 `AutoFields`, setting the pk to None will work.

 For implementation the problems are: How to trac primary key changes? Some
 fields are mutable inplace, which makes the problem harder. Model
 `__init__` should not be made much slower by this.

 Some related tickets: #2259, #4102. There is also a
 [https://groups.google.com/group/django-
 
developers/browse_thread/thread/b028e3c7a366330e/58c37e1988d5d8ef#58c37e1988d5d8ef
 Django-developers thread] about this.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17332>
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