Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32187 closed Bug (fixed)

The .select_related is not necessary in the .update documentation

Reported by: Willem Van Onsem Owned by: Hasan Ramezani
Component: Documentation Version: 3.1
Severity: Normal Keywords: orm, query, documentation
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

This question on StackOverflow is questioning a part of the documentation https://stackoverflow.com/q/64795627/67579

It asks what the use is of the .select_related in:

>>> Entry.objects.select_related().filter(blog=b).update(headline='Everything is the same')

To the best of my knowledge, there is no use of .select_reated in case of a .update(..). Likely the ORM will ignore .select_related and .prefetch_related calls, and if it does not, it can cause problems since an UPDATE ... query with a JOIN ... clause results in problems about what table to update and how.

It thus might be better to omit the .select_related() part here. Likely this is due to copying from another part of the documentation.

Change History (4)

comment:1 by Carlton Gibson, 4 years ago

Triage Stage: UnreviewedAccepted

Yes, looks right.

comment:2 by Hasan Ramezani, 4 years ago

Owner: changed from nobody to Hasan Ramezani
Status: newassigned

comment:3 by GitHub <noreply@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In c448e61:

Fixed #32187 -- Removed unnecessary select_related in queries doc.

comment:4 by Carlton Gibson <carlton.gibson@…>, 4 years ago

In eba8d6f:

[3.1.x] Fixed #32187 -- Removed unnecessary select_related in queries doc.

Backport of c448e614c60cc97c6194c62052363f4f501e0953 from master

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