#24041: db.models.base.save() has unexpected behaviour when a primary key field
value is changed
----------------------------------------------+--------------------
     Reporter:  vedantlath                    |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.7
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 When the value of a primary key field in a record is changed in the admin
 interface, a new record gets created and the previous record is untouched.
 This means that the primary key field of a model is effectively read-only
 and its values cannot be changed.

 Steps to reproduce:
 1. Define a model M as:
 {{{
 class M(models.Model):
     name = models.CharField(max_length=200, primary_key=True)
 }}}

 2. Create a record in M with name as 'ABC' and save it.
 3. Change the name in the above record to 'XYZ' and save it.

 Expected result:
 the record 'ABC' is changed to 'XYZ' with an SQL UPDATE command.

 Actual result:
 a new record 'XYZ' is created and the previous record 'ABC' also exists.
 No warning or any other message is shown.

 If this is intended behaviour, it should be documented appropriately in
 the primary_key parameter and maybe other places.

--
Ticket URL: <https://code.djangoproject.com/ticket/24041>
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 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.fa2657521d37e790546013ae5a8537e4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to