Closed ledburyb closed 2 years ago
The following test case demonstrates one of the cases under which this fails. I investigated the cause of this and found it to be https://github.com/django/django/blob/7acef095d73322f45dcceb99afa1a4e50b520479/django/db/models/sql/compiler.py#L167. This alters the group by statement to just be grouped by 'id', but this doesn't work with Citus because we are dealing with composite primary keys and also need to include the tenant id in the group by.
def test_aggregate(self): from .models import * projects = self.projects managers = self.project_managers unset_current_tenant() projects_per_manager = ProjectManager.objects.annotate(Count('project_id')) list(projects_per_manager)
This was fixed in 2.4.0
The following test case demonstrates one of the cases under which this fails. I investigated the cause of this and found it to be https://github.com/django/django/blob/7acef095d73322f45dcceb99afa1a4e50b520479/django/db/models/sql/compiler.py#L167. This alters the group by statement to just be grouped by 'id', but this doesn't work with Citus because we are dealing with composite primary keys and also need to include the tenant id in the group by.