Fixed #30491 -- Clarified when save() on object with pk executes INSERT.#11390
Merged
felixxm merged 1 commit intodjango:masterfrom May 28, 2019
bsolomon1124:doc-insert-update-pk
Merged
Fixed #30491 -- Clarified when save() on object with pk executes INSERT.#11390felixxm merged 1 commit intodjango:masterfrom bsolomon1124:doc-insert-update-pk
felixxm merged 1 commit intodjango:masterfrom
bsolomon1124:doc-insert-update-pk
Conversation
felixxm
reviewed
May 20, 2019
Contributor
Author
|
I've amended this one based on your comment above @felixxm . Do you think duplicating the short code example from topics/db/models/#field-options would be useful here too, or would it be overkill? |
Member
|
@bsolomon1124 Thanks! I think an example is not necessary, I rephrased your clarification. |
felixxm
pushed a commit
that referenced
this pull request
Sep 2, 2020
felixxm
pushed a commit
that referenced
this pull request
Sep 2, 2020
…callable. Backport of 0bf627f from master
rgs258
pushed a commit
to rgs258/django
that referenced
this pull request
Dec 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket: https://code.djangoproject.com/ticket/30491
The docs for 'How Django knows to UPDATE vs. INSERT'
do not make any mention of a potentially confusing condition,
which is that updating a PK followed by a call to
.save()will always result in an INSERT rather than an UPDATE.
While this note is present in the primary key docstring
itself, it would be worthwhile to duplicate it to this section
as a gotcha.
See also: https://stackoverflow.com/q/56212145/7954504