aggregate(Sum('x')) returns None

529 views
Skip to first unread message

kesmit

unread,
Aug 16, 2009, 11:37:10 PM8/16/09
to Django users
I've noticed that the Sum('x') function will return None if there are
no records in the queryset. This doesn't seem correct to me.
Shouldn't Sum always return a Decimal? It makes it difficult to
compute more complex expressions when you can't depend on a number
being returned.

M. Can Bayrak

unread,
Nov 23, 2011, 1:24:33 PM11/23/11
to django...@googlegroups.com
Agree, i think sum must return decimal. Same problem with me.

Cal Leeming [Simplicity Media Ltd]

unread,
Nov 24, 2011, 5:56:53 AM11/24/11
to django...@googlegroups.com
None != 0

If no rows were encountered, then None should be returned, because there was no data to aggregate, thus how can it logically come back with 0?

I'm -1 on this

On Wed, Nov 23, 2011 at 6:24 PM, M. Can Bayrak <miratca...@gmail.com> wrote:
Agree, i think sum must return decimal. Same problem with me.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/tS-EZk6nTbEJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages