Open pmg103 opened 4 years ago
As per https://docs.djangoproject.com/en/2.2/topics/db/aggregation/#combining-multiple-aggregations:
Combining multiple aggregations with annotate() will yield the wrong results because joins are used instead of subqueries
Therefore I understand that if any serialization_spec contains multiple aggregations over different fields, eg:
serialization_spec
serialization_spec = [ ... {total_age: SumOf('users__age')}, {total_height: SumOf('users__height')}, ]
Then this will return the wrong result.
It occurs to me that we could do better than django on this (which merely notes that the wrong results would be returned in its docs) by either:
As per https://docs.djangoproject.com/en/2.2/topics/db/aggregation/#combining-multiple-aggregations:
Therefore I understand that if any
serialization_spec
contains multiple aggregations over different fields, eg:Then this will return the wrong result.
It occurs to me that we could do better than django on this (which merely notes that the wrong results would be returned in its docs) by either: