django/django — pull request #90 by akaariai (2012-05-23 20:31:20+00:00)
Title: Fix qs.order_by() join promotion for already existing joins

When order_by causes new joins to be added to the query, the joins must
be LEFT OUTER joins for nullable relations, otherwise the order_by
could cause the results to be altered. This commit fixed the logic to
only promote new joins, previously all applicable joins were promoted.

Thanks to Bruno Desthuilliers for spotting this corner case.