Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Should we disallow combining aggregations? #28

Open
pmg103 opened this issue Nov 11, 2019 · 0 comments
Open

Should we disallow combining aggregations? #28

pmg103 opened this issue Nov 11, 2019 · 0 comments

Comments

@pmg103
Copy link
Contributor

pmg103 commented Nov 11, 2019

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 = [
    ...
    {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:

  1. Making this work somehow waves hands; or at least
  2. Making this illegal -- raise a validation error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant