#33276: Strange difference for prefetched_objects between related_field.remove,
m2m_related_field.remove and generic_related_field.remove.
-------------------------------------+-------------------------------------
     Reporter:  Maxim Danilov        |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  3.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  prefetch_related     |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi Maxim.

 > i want to call _remove_prefetched_objects only to remove cached old
 data. But i dont want to use private method.
 >
 > instance.m2m_related_field.remove() - made what i want.

 This doesn't sound right. 🤔
 `remove()` will (erm) **remove** the objects from the M2M relation, not
 just ''remove cached old data'' — it alters the data in the DB.

 If you just want to remove the prefetch cache I think you'll need to use
 the private method, or call `refresh_from_db()`, or similar.

 The `_clear()` method is a shared helper between `remove()` and `clear()`.
 Moving the `_remove_prefetched_objects()` to the public methods will just
 cause duplication of the implementation there. I don't think that's a
 change we want to make.

 Thanks.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33276#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 on the web visit 
https://groups.google.com/d/msgid/django-updates/067.0b78c7d4433540238e1811a94b13e98e%40djangoproject.com.

Reply via email to