diff options
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index f08544d259..0a5e428897 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1474,6 +1474,13 @@ class Query(object): query.bump_prefix() query.clear_ordering(True) query.set_start(prefix) + # Adding extra check to make sure the selected field will not be null + # since we are adding a IN <subquery> clause. This prevents the + # database from tripping over IN (...,NULL,...) selects and returning + # nothing + alias, col = query.select[0] + query.where.add((Constraint(alias, col, None), 'isnull', False), AND) + self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, can_reuse=can_reuse) |
