[Django] #30491: Make note on exception to UPDATE-v-INSERT logic

10 views
Skip to first unread message

Django

unread,
May 19, 2019, 5:54:49 PM5/19/19
to django-...@googlegroups.com
#30491: Make note on exception to UPDATE-v-INSERT logic
------------------------------------------------+------------------------
Reporter: Brad | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.2
Severity: Normal | Keywords: save
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/30491>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 20, 2019, 7:53:50 AM5/20/19
to django-...@googlegroups.com
#30491: Document changing primary key behavior in "How Django knows to UPDATE vs.
INSERT" section.
--------------------------------------+------------------------------------
Reporter: Brad | Owner: Brad
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.2
Severity: Normal | Resolution:
Keywords: save | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* status: new => assigned
* owner: nobody => Brad
* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/30491#comment:1>

Django

unread,
May 20, 2019, 7:54:24 AM5/20/19
to django-...@googlegroups.com
#30491: Document changing primary key behavior in "How Django knows to UPDATE vs.
INSERT" section.
--------------------------------------+------------------------------------
Reporter: Brad | Owner: Brad
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.2

Severity: Normal | Resolution:
Keywords: save | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30491#comment:2>

Django

unread,
May 24, 2019, 7:04:31 AM5/24/19
to django-...@googlegroups.com
#30491: Document changing primary key behavior in "How Django knows to UPDATE vs.
INSERT" section.
--------------------------------------+------------------------------------
Reporter: Brad | Owner: Brad
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 2.2

Severity: Normal | Resolution:
Keywords: save | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30491#comment:3>

Django

unread,
May 28, 2019, 5:28:27 AM5/28/19
to django-...@googlegroups.com
#30491: Document changing primary key behavior in "How Django knows to UPDATE vs.
INSERT" section.
--------------------------------------+------------------------------------
Reporter: Brad | Owner: Brad
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.2
Severity: Normal | Resolution: fixed

Keywords: save | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"67b6cb7723b2765cb776bd59d5603e3e63eefc2e" 67b6cb77]:
{{{
#!CommitTicketReference repository=""
revision="67b6cb7723b2765cb776bd59d5603e3e63eefc2e"
Fixed #30491 -- Clarified when save() on object with pk executes INSERT.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30491#comment:4>

Django

unread,
May 28, 2019, 5:29:25 AM5/28/19
to django-...@googlegroups.com
#30491: Document changing primary key behavior in "How Django knows to UPDATE vs.
INSERT" section.
--------------------------------------+------------------------------------
Reporter: Brad | Owner: Brad
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.2

Severity: Normal | Resolution: fixed
Keywords: save | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"0f0d1cd7722238158011c7717d410fae37513ceb" 0f0d1cd]:
{{{
#!CommitTicketReference repository=""
revision="0f0d1cd7722238158011c7717d410fae37513ceb"
[2.2.x] Fixed #30491 -- Clarified when save() on object with pk executes
INSERT.

Backport of 67b6cb7723b2765cb776bd59d5603e3e63eefc2e from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30491#comment:5>

Reply all
Reply to author
Forward
0 new messages