summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-06-10 18:22:30 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2013-06-14 16:29:06 +0300
commit89bf7a45250cf554295f3d17d708311d3edba101 (patch)
tree97b841a7d37e41d4c794c812d9e6f3b4411dd2f9 /django/db/models/sql
parentb7bd7087e6480c6a071a12ce20b389a8c225e908 (diff)
Fixed #20528 -- regression in select_related join promotion
The join used by select_related was incorrectly INNER when the query had an ORed filter for nullable join that was trimmed away. Fixed this by forcing the join type to LOUTER even when a join was trimmed away in ORed queries.
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 154b6bd204..d26b8d5c95 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1913,5 +1913,7 @@ def alias_diff(refcounts_before, refcounts_after):
Given the before and after copies of refcounts works out which aliases
have been added to the after copy.
"""
+ # Use -1 as default value so that any join that is created, then trimmed
+ # is seen as added.
return set(t for t in refcounts_after
- if refcounts_after[t] > refcounts_before.get(t, 0))
+ if refcounts_after[t] > refcounts_before.get(t, -1))