From cbd1e913ef9fd9ef3a59a8607b2c9ccc34a64db3 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Mon, 27 Nov 2023 11:49:24 +0100 Subject: [PATCH] [5.0.x] Fixed #34978, Refs #31331 -- Added backward incompatibility note about raw aggregations on MySQL. Thanks Matthew Somerville for the report. Backport of a652f0759651dd7103ed04336ef85dc410f680c1 from main --- docs/releases/4.2.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 59f144a15c..4bc68bb8a4 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -409,6 +409,16 @@ fields modified in the custom ``save()`` methods should be added to the ``update_fields`` keyword argument before calling ``super()``. See :ref:`overriding-model-methods` for more details. +Dropped support for raw aggregations on MySQL +--------------------------------------------- + +MySQL 8+ allows functional dependencies on ``GROUP BY`` columns, so the +pre-Django 4.2 workaround of grouping by primary keys of the main table is +removed. As a consequence, using ``RawSQL()`` aggregations is no longer +supported on MySQL as there is no way to determine if such aggregations are +needed or valid in the ``GROUP BY`` clause. Use :ref:`aggregation-functions` +instead. + Miscellaneous -------------