﻿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
10657	Meta option 'ordering' causes problems with nullable fields	andrewl	nobody	"See also ticket:10574 which basically seems to be talking about the same thing under a slightly different setup.

Specifying fields which may be null in the Meta option 'ordering' causes problems later on when retrieving model records. 

See the attached Model definition and fixture for an example. Note that the Model definition appears to require one 'level' of inheritance for the problem to occur (hence the Animal-Person/Pet relationship) - the model and fixture files with the suffix 'safe' demonstrate a similar setup which does not suffer from the problem.

To reproduce the problem, set up the example application with the fixture, and try House.objects.all().count(), which will return the correct count of 2. However House.objects.all() will return only 1 House - the missing House has a null record for the 'pet' field. House.objects.all().order_by() returns both Houses.

The problem should either be fixed or (as I recognise that the underlying problem is a tad complex) the [http://docs.djangoproject.com/en/dev/ref/models/options/#ordering/ Model Meta options documentation on the 'ordering' option] should include a note to the effect that 'Ordering by nullable fields, though legal, is unpredictable'."	Bug	closed	Database layer (models, ORM)	1.0	Normal	fixed	ordering, order_by		Design decision needed	0	0	0	0	0	0
