#36372: refresh_from_db with explicit fields can't clear a relation unless it's
prefetched
-------------------------------------+-------------------------------------
Reporter: Roman Donchenko | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.2
(models, ORM) |
Severity: Normal | Resolution:
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):
* cc: Mariusz Felisiak, Simon Charette (added)
Comment:
For context, clearing the prefetch cache was added as part of #29625
Given that `fields` can include relations that **exist** in the cache, I
think the docs could be more specific here:
https://docs.djangoproject.com/en/5.2/ref/models/instances/#django.db.models.Model.refresh_from_db
> It is possible to force the set of fields to be loaded by using the
`fields` argument.
It's not clear to me that this should do nothing (rather than error) if
the relation is not prefetched given this has been explicitly specified as
a field to "refresh"
Hoping to get the opinion of a few others here
--
Ticket URL: <https://code.djangoproject.com/ticket/36372#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/01070196aa6eedbb-cba6618e-1534-431a-98b6-c9d07a08749b-000000%40eu-central-1.amazonses.com.