Re: [Django] #33975: __in doesn't clear selected fields on the RHS when QuerySet.alias() is used after annotate(). (was: Using .filter with lookup field__in=queryset where queryset contains .annotate and .alias fails)

5 views
Skip to first unread message

Django

unread,
Sep 2, 2022, 5:45:39 AM9/2/22
to django-...@googlegroups.com
#33975: __in doesn't clear selected fields on the RHS when QuerySet.alias() is used
after annotate().
-------------------------------------+-------------------------------------
Reporter: Gabriel Muj | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 4.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: closed => new
* cc: Simon Charette, Alexandr Tatarinov (added)
* resolution: invalid =>
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Replying to [comment:3 Gabriel Muj]:
> Using either {{{.alias}}} or {{{.annotate}}} works as expected without
using {{{.values}}} to limit to 1 column. Why is that? but using both of
them doesn't seem work.

We have some simplification in the `__in` lookup that automatically limit
selected fields to the `pk` when `Query` is on the right-side and the
selected fields are undefined. It looks like they don't play nice when
`.annotate()` and `.alias()` are mixed. Tentatively accepted for the
investigation.

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

Reply all
Reply to author
Forward
0 new messages