#34748: __in lookup crashes with a subquery containing an unused annotation that uses explicit grouping. -------------------------------------+------------------------------------- Reporter: Toan Vuong | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 4.2 (models, ORM) | Severity: Release blocker | 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):
* severity: Normal => Release blocker * cc: Simon Charette (added) * component: Uncategorized => Database layer (models, ORM) * type: Uncategorized => Bug * stage: Unreviewed => Accepted Comment: Thanks for the report! Regression in dd68af62b2b27ece50d434f6a351877212e15c3f. I was also able to reproduce this issue without the second `values_list()`: {{{ >>> inner_qs = ( Comment.objects.annotate(question_id=F('choice__question__id')) .values('question_id') .annotate(cnt=Count('*')) ) >>> outer_qs = Question.objects.filter(id__in=inner_qs).all() >>> print(outer_qs.query) SELECT "ticket_34738_question"."id", "ticket_34738_question"."question_text", "ticket_34738_question"."pub_date" FROM "ticket_34738_question" WHERE "ticket_34738_question"."id" IN (SELECT U1."question_id" AS "question_id", COUNT(*) AS "cnt" FROM "ticket_34738_comment" U0 INNER JOIN "ticket_34738_choice" U1 ON (U0."choice_id" = U1."id") GROUP BY "ticket_34738_choice"."question_id") }}} -- Ticket URL: <https://code.djangoproject.com/ticket/34748#comment:2> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/010701899ae409ca-278e167e-1323-419a-97fd-adf16d7321cc-000000%40eu-central-1.amazonses.com.