Via the magic of time machines, this has already been done on
queryset-refactor branch. You also need it with certain "or"
combinations of queries.
Malcolm
I think you'll be safe. The only difference is that certain rows won't
appear when the right-hand side of the match doesn't exist. If you're
comparing to explicit (non-null) values, it should be fine. All the
cases I can think of where outer joins are required are not working
reliably on trunk anyway, so filtered relations are the only case you'll
be relying on.
Malcolm
When it is ready. I"m putting as much time into it as I have spare (and
then some), although I have to keep stopping to work on higher priority
tickets, so it's not 100% of my available time.
> Now INNER JOIN isnull lookup parameter does not work for related
> models because INNER JOIN produce cartesian product between the
> specified tables (that is, each and every row in the first table is
> joined to each and every row in the second table) so there is no NULL
> records in the right table.
Yes, I understand how inner joins work.
> That means we cannot use it to find rows in a table that have no
> counterpart in another table like is done below:
>
> SELECT left_tbl.*
> FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id
> WHERE right_tbl.id IS NULL;
>
> I looked though queryset-refactor branch.. There is so many changes so
> I doubt that we can have it in trunk in a reasonable time.
You can have your doubts if you like. I don't think they're correct.
Indeed "when it is ready" is the very definition of "reasonable time".
> How can we now solve the task of "how to find rows in a table that
> have no counterpart in another table" ?
This is already fixed in the queryset-refactor branch, as demonstrated
here:
http://code.djangoproject.com/browser/django/branches/queryset-refactor/tests/regressiontests/queries/models.py#L157
Regards,
Malcolm