Ticket #13815: 13815.patch
File 13815.patch, 1.4 KB (added by , 14 years ago) |
---|
-
django/db/models/sql/query.py
1419 1419 query.bump_prefix() 1420 1420 query.clear_ordering(True) 1421 1421 query.set_start(prefix) 1422 # Adding extra check to make sure the selected field will not be null 1423 # since we are adding a IN <subquery> clause. This prevents the 1424 # database from tripping over IN (...,NULL,...) selects and returning 1425 # nothing 1426 alias, col = query.select[0] 1427 query.where.add((Constraint(alias, col, None), 'isnull', False), AND) 1428 # end of hack 1422 1429 self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, 1423 1430 can_reuse=can_reuse) 1424 1431 -
tests/regressiontests/null_queries/models.py
77 77 >>> _ = Inner.objects.create(first=obj) 78 78 >>> Inner.objects.filter(first__inner__second=None) 79 79 [<Inner: Inner object>] 80 >>> objB = OuterB.objects.create(data="reverse") 81 >>> OuterB.objects.filter(inner__isnull=False) 82 [] 83 >>> _ = Inner.objects.create(first=obj) 84 >>> OuterB.objects.exclude(inner__isnull=False) 85 [<OuterB: OuterB object>] 80 86 81 82 87 """}