[Django] #33596: subsequent calls to prefetch_related_objects() don't work for model instances that have changed

4 views
Skip to first unread message

Django

unread,
Mar 22, 2022, 3:09:47 PM3/22/22
to django-...@googlegroups.com
#33596: subsequent calls to prefetch_related_objects() don't work for model
instances that have changed
-------------------------------------+-------------------------------------
Reporter: Dennis | Owner: nobody
Kliban |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Our project processes instances in a stream. In some cases the instances
are repeated. In these cases, we discovered that
prefetch_related_objects() does not work correctly if the list of related
objects has changed since the first time prefetch_related_objects() on the
instance. I've written a simple reproducer here[0].

In the reproducer, if I call `delattr(book, "the_authors")` after adding
the author, everything works.

[0]
https://github.com/django/django/commit/73a138665ba20915f51680816120727a5e2ba771

--
Ticket URL: <https://code.djangoproject.com/ticket/33596>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages