diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-28 15:04:12 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-28 15:05:48 +0200 |
| commit | 06de130dae8b7a6c95143077d7a82fab37da0bc0 (patch) | |
| tree | bacdf702b0a0f8c4a91d7c695f754453161b3657 /django | |
| parent | 481f3f13b54a5cacc5b67b32c4ada267fc709d21 (diff) | |
Fixed #12823 -- Was already fixed in master, tests added
Also added a little improvement to sql/query.py to get rid of
non-necessary IS NOT NULL check.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/sql/query.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 64a3e7075b..9af7544db3 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1204,7 +1204,8 @@ class Query(object): if negate: self.promote_joins(join_list) - if lookup_type != 'isnull' and (self.is_nullable(target) or len(join_list) > 1): + if (lookup_type != 'isnull' and ( + self.is_nullable(target) or self.alias_map[join_list[-1]].join_type == self.LOUTER)): # The condition added here will be SQL like this: # NOT (col IS NOT NULL), where the first NOT is added in # upper layers of code. The reason for addition is that if col @@ -1447,7 +1448,7 @@ class Query(object): # nothing if self.is_nullable(query.select[0].field): alias, col = query.select[0].col - query.where.add((Constraint(alias, col, None), 'isnull', False), AND) + query.where.add((Constraint(alias, col, query.select[0].field), 'isnull', False), AND) # Still make sure that the trimmed parts in the inner query and # trimmed prefix are in sync. So, use the trimmed_joins to make sure |
