Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30491 closed Cleanup/optimization (fixed)

Document changing primary key behavior in "How Django knows to UPDATE vs. INSERT" section.

Reported by: Brad Owned by: Brad
Component: Documentation Version: 2.2
Severity: Normal Keywords: save
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

PR: https://github.com/django/django/pull/11390

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

Change History (5)

comment:1 by Mariusz Felisiak, 5 years ago

Owner: changed from nobody to Brad
Status: newassigned
Summary: Make note on exception to UPDATE-v-INSERT logicDocument changing primary key behavior in "How Django knows to UPDATE vs. INSERT" section.
Triage Stage: UnreviewedAccepted

This note is already in topics/db/models and ref/models/fields, but I agree that we can add it in one more place.

comment:2 by Mariusz Felisiak, 5 years ago

Has patch: set

comment:3 by Mariusz Felisiak, 5 years ago

Patch needs improvement: set

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 67b6cb77:

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

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 0f0d1cd:

[2.2.x] Fixed #30491 -- Clarified when save() on object with pk executes INSERT.

Backport of 67b6cb7723b2765cb776bd59d5603e3e63eefc2e from master

Note: See TracTickets for help on using tickets.
Back to Top