#35044: Accessing a deferred field clears reverse relations
-------------------------------------+-------------------------------------
     Reporter:  Adam Johnson         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * type:  Cleanup/optimization => Bug
 * stage:  Unreviewed => Accepted


Comment:

 Feels like a bug to me.

 When `refresh_from_db(fields)` is specified it should likely not clear
 reverse relationships and I think the same can be said about

 Regression in a7b5ad8b19a08d7d57302ece74f6e26d2887fd9f #27846 for reverse
 relations and possibly 123b1d3fcf79f091573c40be6da7113a6ef35b62 #34137 for
 private fields. The private field situation is more complex though as they
 might be composed of other fields (e.g. `GenericForeignKey`) but the field
 APIs doesn't expose a generic way of introspecting that so I would assume
 we'd still want to clear .

 An alternative here would be to accept another kwarg to denote field cache
 clearing that would default to `True` and that `DeferredAttribute.__get__`
 would pass `False` to.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35044#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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018c73b93d0f-6b95e634-1536-4e39-a121-329ef4dc0f93-000000%40eu-central-1.amazonses.com.

Reply via email to