#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
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):
In [changeset:"8aea6b802ced18a54f00db71c53e09c643f7514c" 8aea6b8]:
{{{#!CommitTicketReference repository=""
revision="8aea6b802ced18a54f00db71c53e09c643f7514c"
[5.2.x] 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.
Backport of 2598b371a93e21d84b7a2a99b2329535c8c0c138 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35677#comment:20>
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/01070194db76c65d-0328e46d-2e03-4294-a2a6-7336cf6998b0-000000%40eu-central-1.amazonses.com.