Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2026-03-26 Thread Django
#36507: Document that only the base queryset’s prefetch_related() is preserved 
when
using union()
-+-
 Reporter:  Clifford Gama|Owner:  Chris M
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  5.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  union  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jacob Walls):

 * needs_better_patch:  0 => 1

-- 
Ticket URL: 
Django 
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/0107019d2bc6be17-4ad8181c-a868-4873-ac27-f203bee27214-00%40eu-central-1.amazonses.com.


Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2025-10-17 Thread Django
#36507: Document that only the base queryset’s prefetch_related() is preserved 
when
using union()
-+-
 Reporter:  Clifford Gama|Owner:  Chris M
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Database layer   |  Version:  5.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  union  |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Chris M):

 * has_patch:  0 => 1
 * owner:  Clifford Gama => Chris M

Comment:

 I have made an attempt at documenting this behavior in this
 [https://github.com/django/django/pull/19929 PR].

 I'm open to thoughts on how to improve this documentation: if it should
 exist somewhere else or if any changes are needed. It is a pretty nuanced
 topic, and I was trying to balance covering the details without making it
 too confusing.

 I included an example of using `Q` objects to filter within the first
 `prefetch_related`. However, I'm not sure this is all that helpful of an
 example to provide. It feels like it introduces a bit too much complexity
 to the documentation.
-- 
Ticket URL: 
Django 
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/01070199c1fc0758-87ed0084-03a0-4ca2-812d-64f31a283d7f-00%40eu-central-1.amazonses.com.


Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2025-07-22 Thread Django
#36507: Document that only the base queryset’s prefetch_related() is preserved 
when
using union()
-+-
 Reporter:  Clifford Gama|Owner:  Clifford
 Type:   |  Gama
  Cleanup/optimization   |   Status:  assigned
Component:  Database layer   |  Version:  5.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  union  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Clifford Gama):

 * owner:  (none) => Clifford Gama
 * status:  new => assigned

-- 
Ticket URL: 
Django 
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/0107019831e95801-48630351-caf1-44de-90dc-1215d258866f-00%40eu-central-1.amazonses.com.


Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2025-07-16 Thread Django
#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:  Database layer   |  Version:  5.2
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  prefetch_related,| Triage Stage:  Accepted
  union  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Natalia Bidart):

 * component:  Documentation => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted

Comment:

 Makes sense, thank you Clifford!
-- 
Ticket URL: 
Django 
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/01070198137946ce-31080252-82f9-4ea9-aaa1-25a33bd64bd0-00%40eu-central-1.amazonses.com.


Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2025-07-15 Thread Django
#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
-+-
Changes (by Sniom):

 * cc: Sniom (added)

-- 
Ticket URL: 
Django 
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/010701980e5ec0f7-f595ee67-d499-4367-8c7c-2fb3928d51e2-00%40eu-central-1.amazonses.com.


Re: [Django] #36507: Document that only the base queryset’s prefetch_related() is preserved when using union()

2025-07-14 Thread Django
#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: 
Django 
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-00%40eu-central-1.amazonses.com.