#29625: Expose RelatedManager._remove_prefetched_objects as public method
-------------------------------------+-------------------------------------
Reporter: Ming Qin | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: prefetch_related, | Triage Stage: Accepted
_prefetched_objects_cache |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Replying to [comment:5 Ming Qin]:
> No, it doesn't work. Still hits the cache. Tested on `master`, `2.1rc1`,
and `2.1`.
> I'll be happy to fix `refresh_from_db`, instead of opening this new API.
>
> Does the following behavior sound good?
> 1. If `refresh_from_db()` is called without argument, it **won't** clear
prefetched cache.
> 2. If it's called specifically with an related field, and that field is
many-to-many or many-to-one field, the prefetched cache **will** be
cleared.
>
1. No, it should clear all fields prefetched cache like it does right now
with non-prefetched related manager cache.
2. I haven't investigated but it looks like `ManyToManyField.is_cached`
and `ManyToMany.delete_cached_value` might need to be redefined from
`Field` in order to take `instance._prefetched_objects_cache` into
consideration as well. It'd be interesting to test how prefetched foreign
keys and o2o behave here as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/29625#comment:6>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.3d4cbd13aafaa39468e5daefa235f04b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.