﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14548	Docs and implementation don't match regading return values of certain QuerySet aggregate functions	Paul McMillan	nobody	"The [http://docs.djangoproject.com/en/1.2/ref/models/querysets/#aggregation-functions aggregation docs] specify that `Max`, `Min`, or `Sum` return a value of the same type as the field on which the function was called. This means that if I use `Max()` on a `PositiveIntegerField`, I expect to get back a Python `int`.

I know that a non-null `PositiveIntegerField` can't contain None - setting and saving it throws an IntegrityError.

However, when I use the `Max()` aggregate on a PositiveIntegerField in a model with no rows, I get back `None`. This behavior occurs in both sqlite and PostgreSQL.

Since this behavior has (presumably) been around since aggregates were introduced, this must be a bug in the docs, and not in Django, even though it is counterintuitive and requires boilerplate code to make absolutely certain that the value is not `None` before depending on the typing.

If it were up to me, I would propose changing the return value to be in line with the docs, but that wouldn't be backwards compatible."	Bug	closed	Documentation	1.2	Normal	duplicate			Accepted	0	0	0	0	0	0
