﻿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
3149	select_related() filters objects with ANY fk foreign relation	Doug Napoleone	Adrian Holovaty	"This is different from not following FK relations with null=True which is documented. 
This is select_related() EXCLUDING relations with any fk null=True where ANY fk row entry is Null.

>>> ScheduledEvent.objects.filter(room__isnull=True)
[<ScheduledEvent: ScheduledEvent object>]
>>> ScheduledEvent.objects.filter(room__isnull=True).select_related()
[]
>>>

ScheduledEvents have other FK's besides 'room' which are not 'null=True', for which select_related() gives a good speedup (5x over 8000 rows w/ 4 FK's). Unfortunatly it excludes all relations with a null room FK.

My current workaround is to create a special 'NULL' room which now needs to be queried for, the id cached, and .exclude(room=NullRoomId) added as a special object manager on the class. Less than optimal and would hate to have to do with for all my null=True fk relations, but might help others with this problem.
"	defect	closed	Database layer (models, ORM)	dev	normal	worksforme	select_related() null=True		Unreviewed	0	0	0	0	0	0
