﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34262	Queryset grouped by annotation with aggregates on another annotated expression crashes on MySQL with sql_mode=only_full_group_by.	Mariusz Felisiak	ontowhee	"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"")
}}}"	Bug	closed	Database layer (models, ORM)	4.1	Normal	fixed	mysql only_full_group_by	Simon Charette David Wobrock	Ready for checkin	1	0	0	0	0	0
