#26434: Inconsistent results of QuerySet count() method using PostgreSQL backend
prior and post the QuerySet evaluation
-------------------------------------+-------------------------------------
Reporter: kamandol | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: postgresql queryset | Triage Stage: Accepted
count annotate aggreagate |
order_by |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Can Sarıgöl):
I want to discuss when collecting group by columns why are order by
columns added into extensions.
For example:
Model.objects.values("col_a").annotate(max=Max("col_b")).order_by('col_c')
current query:
{{{
select col_a, MAX(col_b) as max
from Model
group by col_a, col_c
order by col_c
}}}
I think the expected behavior has should be like that:
django.db.utils.ProgrammingError: column "Model.col_c" must appear in the
GROUP BY clause or be used in an aggregate function
Because this behavior changes my group by and result. if I'm lucky, my
result doesn't change.
If we check test_annotation_with_value, 'name' column is being added into
group_by because Book model has Meta.ordering.
--
Ticket URL: <https://code.djangoproject.com/ticket/26434#comment:11>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.cd6042641a66b7aea9cc347fa7e8548a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.