While addressing the issue is complex and will require quite a bit of work to solve in a backward-compatible way I believe that it should be feasible to emit a MultipleMultiValuedJoin(RuntimeWarning) with pointers for alternatives (e.g. using subqueries) without too much hassle when aggregation is performed and more than one multi-valued relationship is involved.
The docs you pointed at mention the multiple aggregation problem but a similar thing happens when filtering against a multi-valued relationship after a single aggregation[0] so the problem can be generalized to any form of aggregation on a query that joins more than one multi-valued relationship (n-to-many). Simon [0] https://code.djangoproject.com/ticket/33403 Le mercredi 5 janvier 2022 à 09:59:24 UTC-5, Yonas a écrit : > In that case, at least there should be a warning message in the > documentation. And what do you think of the example? Isn't it contradicting > the documentation? > > On Wednesday, January 5, 2022 at 5:16:43 PM UTC+3 niccol...@gmail.com > wrote: > >> I would be in favor of a real time information about the issue. >> Il giorno mercoledì 5 gennaio 2022 alle 15:13:17 UTC+1 Yonas ha scritto: >> >>> Hello, >>> >>> There's a ticket <https://code.djangoproject.com/ticket/10060> opened >>> 13 years ago explaining a problem with combining multiple aggregations with >>> annotate(). And the solution appears to be documenting >>> <https://docs.djangoproject.com/en/4.0/topics/db/aggregation/#combining-multiple-aggregations> >>> the >>> problem. >>> >>> But for people skimming through the documentation, the message might not >>> be noticeable. Showing the problem in a warning message could help draw >>> attention better. It's used here >>> <https://docs.djangoproject.com/en/4.0/ref/settings/#static-root> and >>> in other places in the doc. >>> >>> In addition to documenting the problem, raising an exception might >>> prevent developers from spending hours trying to debug their code. >>> >>> While the problem is recognized, there's an example >>> <https://docs.djangoproject.com/en/4.0/topics/db/aggregation/#joins-and-aggregates>in >>> >>> the documentation that shows the usage of multiple aggregations. >>> >> -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/80f94136-fc8a-4d74-9e1f-c3da77c22bc1n%40googlegroups.com.