#36372: refresh_from_db with explicit fields can't clear a relation by it's query
name unless it's prefetched
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* resolution: => wontfix
* status: new => closed
* summary:
refresh_from_db with explicit fields can't clear a relation unless
it's prefetched
=>
refresh_from_db with explicit fields can't clear a relation by it's
query name unless it's prefetched
Comment:
Thank you Simon
Confirmed that adding `related_name="items"` and calling
`refresh_from_db(fields=["items"])` doesn't crash
> Changing ForeignObjectRel.name to default to .accessor_name is tempting
here but that would likely break tons of things.
As this can be resolved on the model level, I will close this as wontfix
for now.
If we receive a non-invasive fix to support this, I think we would be open
to accepting a patch
--
Ticket URL: <
https://code.djangoproject.com/ticket/36372#comment:4>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.