#35677: Unexpected behaviour of Prefetch with queryset filtering on a through
model
-------------------------------------+-------------------------------------
Reporter: David Glenck | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: Prefetch, | Triage Stage: Ready for
prefetch_related, many-to-many | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):
* resolution: => fixed
* status: assigned => closed
Comment:
In [changeset:"2598b371a93e21d84b7a2a99b2329535c8c0c138" 2598b371]:
{{{#!CommitTicketReference repository=""
revision="2598b371a93e21d84b7a2a99b2329535c8c0c138"
Fixed #35677 -- Avoided non-sticky filtering of prefetched many-to-many.
The original queryset._next_is_sticky() call never had the intended effect
as
no further filtering was applied internally after the pk__in lookup making
it
a noop.
In order to be coherent with how related filters are applied when
retrieving
objects from a related manager the effects of what calling
_next_is_sticky()
prior to applying annotations and filters to the queryset provided for
prefetching are emulated by allowing the reuse of all pre-existing JOINs.
Thanks David Glenck and Thiago Bellini Ribeiro for the detailed reports
and
tests.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35677#comment:19>
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 visit
https://groups.google.com/d/msgid/django-updates/01070194db721c6d-fffbdae4-a688-47aa-a919-6493b0a260c2-000000%40eu-central-1.amazonses.com.