#33984: Related managers cache gets stale after saving a fetched model with new 
PK
-------------------------------------+-------------------------------------
     Reporter:  joeli                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

 > In theory the "simplest" solution (to keep the caching behaviour and
 allow the documented duplication method) is to special-case None as a pk
 value and always instantiate a fresh manager, circumventing the cache
 entirely.

 `None` is already
 
[https://github.com/django/django/blob/32536b1324e98768dd892980408a8c6b26c23fd9/django/db/models/base.py#L931-L940
 handled separately for related objects], so maybe it's enough to refresh
 `related_managers_cache` when `self.pk is None` and they're cached 🤔 I'm
 also happy to revert 4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6 and re-open
 #32980.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33984#comment:7>
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/010701831c682bd7-bcf22bf5-d3d8-43ce-8ef2-6f9427a9d702-000000%40eu-central-1.amazonses.com.

Reply via email to