﻿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
14876	Q | Q with nullable related fields generates INNER JOIN where it should be LEFT JOIN	Simon Percivall	Tomek Paczkowski	"The following example shows that when ORing Q's Person is LEFT OUTER JOINed and House is erroneously INNER JOINed. At the same time ORing querysets works.
{{{
from django.db import models
from django.db.models import Q

class House(models.Model):
    streetname = models.CharField(max_length=255)

class Person(models.Model):
    home = models.ForeignKey(House)

class Rock(models.Model):
    owner = models.ForeignKey(Person, null=True)

# with Q | Q
print Rock.objects.filter(Q(owner__isnull=True) | (Q(owner__home__streetname=''))).query

# with qs | qs
print (Rock.objects.filter(Q(owner__isnull=True)) | Rock.objects.filter(Q(owner__home__streetname=''))).query
}}}
This of course means that owner`__`is_null=True won't work with Q's becaues of the INNER JOIN.

Tested with 1.0.4+, 1.2.3+ and 1.3 trunk@14864"	Bug	closed	Database layer (models, ORM)	1.2	Normal	fixed	Q,inner join,nullable,dceu2011	asendecka@…	Ready for checkin	1	0	0	0	0	0
