Skip to content
/ django Public

Fixed #30491 -- Clarified when save() on object with pk executes INSERT.#11390

Merged
felixxm merged 1 commit intodjango:masterfrom
bsolomon1124:doc-insert-update-pk
May 28, 2019
Merged

Fixed #30491 -- Clarified when save() on object with pk executes INSERT.#11390
felixxm merged 1 commit intodjango:masterfrom
bsolomon1124:doc-insert-update-pk

Conversation

@bsolomon1124
Copy link
Contributor

@bsolomon1124 bsolomon1124 commented May 19, 2019

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

@bsolomon1124 bsolomon1124 changed the title Make note on exception to UPDATE-v-INSERT logic Fixed #30491 - Made note on exception to UPDATE-v-INSERT logic May 19, 2019
@bsolomon1124
Copy link
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?

@felixxm felixxm self-assigned this May 28, 2019
@felixxm felixxm changed the title Fixed #30491 - Made note on exception to UPDATE-v-INSERT logic Fixed #30491 -- Clarified when save() on object with pk executes INSERT. May 28, 2019
@felixxm
Copy link
Member

felixxm commented May 28, 2019

@bsolomon1124 Thanks! I think an example is not necessary, I rephrased your clarification.

@felixxm felixxm merged commit 67b6cb7 into django:master May 28, 2019
@bsolomon1124 bsolomon1124 deleted the doc-insert-update-pk branch May 28, 2019 11:05
felixxm pushed a commit that referenced this pull request Sep 2, 2020
rgs258 pushed a commit to rgs258/django that referenced this pull request Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants