#34262: Queryset grouped by annotation with aggregates on another annotated
expression crashes on MySQL with sql_mode=only_full_group_by.
-------------------------------------+-------------------------------------
Reporter: Mariusz | Owner: nobody
Felisiak |
Type: Bug | Status: new
Component: Database | Version: 4.1
layer (models, ORM) | Keywords: mysql
Severity: Normal | only_full_group_by
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Queryset grouped by annotation with aggregates on another annotated
expression crashed on MySQL with `sql_mode=only_full_group_by`, e.g.
{{{#!python
def test_group_by_nested_expression_with_params(self):
books_qs = (
Book.objects.annotate(greatest_pages=Greatest("pages",
Value(600)))
.values(
"greatest_pages",
)
.annotate(
min_pages=Min("pages"),
least=Least("min_pages", "greatest_pages"),
)
.values_list("least", flat=True)
)
self.assertCountEqual(books_qs, [300, 946, 1132])
}}}
crashes with:
{{{
django.db.utils.OperationalError: (1055, "Expression #1 of SELECT list is
not in GROUP BY clause and contains nonaggregated column
'test_django_2.aggregation_book.pages' which is not functionally dependent
on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_by")
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34262>
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/01070185bbda77ce-a7da31f2-7290-4ef8-b068-b8f2c154a170-000000%40eu-central-1.amazonses.com.