A couple of points regarding this:
http://code.djangoproject.com/ticket/15183#comment:1.
If nulls should not be counted then then they should be excluded from
results but they are not. You always get an entry for nulls (if they
are present) with zero count which if you need them is a problem and
if you don't - it's just a completely useless entry and you must do
some extra coding to get rid of it. That's what I find most confusing
about current Count() implementation.
Conceptual leakage apart, SQL gives user a choice as to how items
should be counted, whereas Django's ORM does not. Neither it is
obvious what goes under the hood until one starts looking into SQL
log.
I think this should be fixed or at least somehow clarified. Possible
ways to address this are the following (in order of my preference):
1) Change current implementation as proposed in my ticket.
2) Allow user to control this behavoiur, e.g.,: Count("my_value",
include_null=True)
3) Clarify current behaviour in documentation: that nulls are never
counted but if present are part of result set with zero count.
BTW, I did bring this to django-dev but due to lack of response
concluded that there were no objections to my proposal:
http://groups.google.com/group/django-developers/browse_thread/thread/9821b79da9d849e?hl=en.
Perhaps I wasn't just clear enough.
Cheers
Sergiy
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.