#28228: changing a primary key and saving results in a new object rather than
renaming the existing object.
-------------------------------------+-------------------------------------
Reporter: Chris Withers | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tom Christie):
I think the "wontfix" resolution against the ticket as stated makes sense.
However, there's a subset of this behavior that isn't documented, which is
the behavior when a primary key is **renamed to the value of an already
existing pk**.
Given this...
> If you change the value of the primary key on an existing object and
then save it, a new object will be created alongside the old one
I would expect to see the same behavior as if attempting to create a new
object with an already used pk. This *ought* to result in an integrity
error, given the uniqueness constraint.
The actual behavior currently is that the existing object will be
overwritten.
That doesn't seem like necessarily the most intuitive outcome, and it's
easy to see how it could introduce unexpected bugs or more-permissive-
than-intended behavior.
I haven't seen this specific subset of the issue isolated in any of the
related tickets/discussions, so I think there might be something worth
considering there.
--
Ticket URL: <https://code.djangoproject.com/ticket/28228#comment:7>
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/064.a7a7371306830f0edac36d9b08c5fac2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.