Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from May 28, 2019
Merged

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

merged 1 commit into from May 28, 2019

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
kwist-sgr pushed a commit to kwist-sgr/django that referenced this pull request Sep 16, 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
2 participants