#21584: prefetch_related child queryset does not update on create
-------------------------------------+-------------------------------------
     Reporter:  lucaswiman           |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  1.6
  (models, ORM)                      |               Resolution:  invalid
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by lucaswiman):

 > This is not a bug, I'm afraid.


  It's very unintuitive that the child_set won't keep track of what
 elements are in it when it is mutated by its own methods. This seems to
 break the "iterable" abstraction.


  >There may be some small exceptions, such as when you update a FK object,
 and the FK ID on that object may be updated as well, but only those that
 can be done with no dependency tracking


 Isn't that precisely the behavior that's being described here?  The
 foreign key relationship should know that a new entry was created, because
 the create method was called on the child_set itself.  Create should
 invalidate the cache, because there's no way the cache can remain valid
 after create is called.  Couldn't create set self._results_cache to None,
 and self.prefetch_done to False when create is called?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21584#comment:2>
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.b7004179741fc8b00159569aab6158b1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to