The same problem occurs with PostreSQL as well: nulls (if present) are
always returned with zero count in aggregates.
Since my post did not stir much of a commotion I conclude that there
are no strong opinions among django developers as to which form of
count should be used in aggregates. So I'll
I want to be able to count how many times each value (including nulls)
is present. I think that exactly what count is for. -:)
Upon a closer look the problem is not limited to foreign keys. When
django generates count clauses in `count()` form here's what
happens (in MySQL at least):
SELECT foo,
Perhaps I'm missing something, but if you count all the defined
foreign keys AND all the null values, won't you just end up with a
count of the parent model? Or are you saying that you explicitly want
to count how many values are null *instead of* defined?
On Jan 25, 2:39 pm, Sergiy Kuzmenko wrot
Hi there!
Annotating a nullable foreign field with Count seems to always return
the count of null values as zero (at least in MySQL environment). A
quick look into this problem reveals that the corresponding SQL clause
is generated as `count()` [1]. This causes to exclude null
values from annotati