#36507: Document that only the base queryset’s prefetch_related() is preserved
when
using union()
-------------------------------------+-------------------------------------
Reporter: Clifford Gama | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: prefetch_related, | Triage Stage:
union | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Clifford Gama:
Old description:
> When using QuerySet.union() in Django, any prefetch_related() applied to
> the second (and third, etc) queryset is silently ignored. See
> [https://forum.djangoproject.com/t/using-union-with-querysets-that-have-a
> -custom-prefetch-object/41638 forum thread in which it was suggested to
> open a documentation ticket]. A docs improvement should also likely
> include the workaround for using `Q` objects to do all prefetches in the
> base qs (where possible), which is suggested by Simon in the forum.
New description:
When using QuerySet.union() (possibly also `intersection()` and
`difference()`) in Django, any `prefetch_related()` applied to the second
(and third, etc) queryset is silently ignored. See
[https://forum.djangoproject.com/t/using-union-with-querysets-that-have-a
-custom-prefetch-object/41638 forum thread in which it was suggested to
open a documentation ticket]. A docs improvement should also likely
include the workaround for using `Q` objects to do all prefetches in the
base qs (where possible), which is suggested by Simon in the forum.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/36507#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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701980b1767ef-9f9aafc0-19f3-4bca-8f93-ee6c4aa2be6b-000000%40eu-central-1.amazonses.com.