{{{
OurModel.objects.none().aggregate(random_aggregate=Sum('field_1')/Count('field_2'))['random_aggregate']
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34972>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => worksforme
Comment:
Hello, thank you for your report.
Could you please provide more details to help us triage this ticket? With
the given information I can't reproduce the exception (I used a simple
model I created for this report).
Specifically, we'd need:
1. Your model definitions to exercise the provided query
2. The exact exception you are getting
Feel free to re-open when you can provide further details.
--
Ticket URL: <https://code.djangoproject.com/ticket/34972#comment:1>
Comment (by Simon Charette):
I think the issue is slightly more complicated than setting
`empty_result_set_value = None` as I would expect
{{{#!python
OurModel.objects.none().aggregate(random_aggregate=Count('field_2')/Count('field_2'))['random_aggregate']
}}}
To return `{"random_aggregate": 0}`.
The fact `NotImplemented` is returned here is problematic though and I
assume you have some third party apps that interacts with query
compilation in a way that does not account for the fact that an aggregate
that doesn't implement `empty_result_set_value` from an empty query should
be evaluated by the database.
--
Ticket URL: <https://code.djangoproject.com/ticket/34972#comment:2>
* cc: David Sanders (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/34972#comment:3>
Comment (by ElRoberto538):
We tried it in a different project and confirmed it worked, I expect this
is an issue with the mssql-django DB connector.
--
Ticket URL: <https://code.djangoproject.com/ticket/34972#comment:4>