#34145: Explicit GROUPing by aggregate is not supported
-------------------------------------+-------------------------------------
Reporter: Karolis Ryselis | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Karolis Ryselis):
The tricky part is when you try to add more fields to group by.
My actual Packing and PackingItem models have more fields, so what I am
actually trying to achieve is something like
{{{#!python
PackingItem.objects.filter(packing__in=my_packings,
amount__gt=0).annotate(tags=GroupConcat('packing__tags',
separator=',')).values('unit', 'good',
'tags').annotate(total_amount=Sum('amount'))
}}}
What happens inside is that unit and good (FK fields in my case) are added
to group by while tags is silently ignored and I get an actual queryset
grouped by part of the fields that I passed to values. I believe that this
is a case where an exception could thrown stating that this is not
supported rather than giving "best effort" result.
--
Ticket URL: <https://code.djangoproject.com/ticket/34145#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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701845bd7f21e-09f6a19e-f9d1-45e1-b484-c28f3c4eb877-000000%40eu-central-1.amazonses.com.