#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 , 5 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 5 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
Yes, looks right.