#35425: .save(force_update=True) not respected for model instances with default
primary keys
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* cc: Simon Charette (added)
* stage: Unreviewed => Accepted
Comment:
Having `save()` always do the expected thing when called on a newly
created instance of a model with a primary key configured with a Python
level default is a complex situation as you've pointed out.
Given the ORM has historically expected newly created model instances to
be used for ''additions'' and uses `_state.adding` to take a decision in
the face of ambiguity I still believe that #29260 was the right thing to
do.
With that being said, when being explicitly told what to do via
`force_update=True` there is no `save` ambiguity and thus we should not
fallback to `force_insert`. In this sense I think this represents a valid
bug and the provided patch seems adequate.
--
Ticket URL: <https://code.djangoproject.com/ticket/35425#comment:4>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018f49798057-7e4448ea-8c0b-49b2-9e45-8190908de160-000000%40eu-central-1.amazonses.com.