﻿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
25772	ArrayField: incorrent len lookup	mrAdm		"Models:
{{{
NullableIntegerArrayModel.objects.create(field=[])
NullableIntegerArrayModel.objects.create(field=[1])
NullableIntegerArrayModel.objects.create(field=[2, 3])
NullableIntegerArrayModel.objects.create(field=[20, 30, 40])
}}}

Queries:
{{{
NullableIntegerArrayModel.objects.filter(field__len=0)
# return: empty queryset
NullableIntegerArrayModel.objects.filter(field__len__lt=2)
# return only one model (field=[1])
}}}

Reason:
PostgreSQL function array_length(ARRAY[]::int4[], 1) return null if array empty.

The solution is to use a function PostgreSQL: COALESCE ().
{{{
SELECT * FROM ... WHERE COALESCE(array_length(""field"", 1), 0)=0
}}}"	Bug	new	contrib.postgres	1.8	Normal				Unreviewed	0	0	0	0	0	0
