#27048: Clear cached_property on refresh_from_db
-------------------------------------+-------------------------------------
     Reporter:  jarekwg              |      Owner:  nobody
         Type:                       |     Status:  new
  Cleanup/optimization               |
    Component:  Core (Cache system)  |    Version:  master
     Severity:  Normal               |   Keywords:  cached_property
                                     |  refresh_from_db
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 Should `cached_property`-decorated stuff get wiped when we call
 `.refresh_from_db()`?

 I found [https://medium.com/@fdemmer/django-cached-property-on-models-
 f4673de33990#.vc5atqt0n this related article] on the matter.

 From a usage perspective, it seems like we wouldn't ever want cached
 properties to persist through a `refresh_from_db()` call, as ideally we'd
 like to think `mymodel.refresh_from_db()` is shorthand synonymous to
 `mymodel = MyModel.objects.get(pk=mymodel.pk)`.

 However, from an implementation perspective, maybe this would result in a
 rabbit hole that tries to pull through other stuff, like #26514.

 Basically this ticket picks at:
    Note that only fields of the model are reloaded from the database.
 Other database dependent values such as annotations are not reloaded.`

 I have a feeling this might be a conscious design decision, but in case it
 isn't, thoughts?

--
Ticket URL: <https://code.djangoproject.com/ticket/27048>
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/050.7afd3e0cdcb3685d62100195a21fe520%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to