Ticket #13815: 13815_2.patch
File 13815_2.patch, 1.6 KB (added by , 14 years ago) |
---|
-
tests/regressiontests/null_queries/tests.py
67 67 ['<Inner: Inner object>'] 68 68 ) 69 69 70 # Ticket #13815: check if <reverse>_isnull=False does not produce 71 # faulty empty lists 72 objB = OuterB.objects.create(data="reverse") 73 self.assertQuerysetEqual( 74 OuterB.objects.filter(inner__isnull=False), 75 [] 76 ) 77 _ = Inner.objects.create(first=obj) 78 self.assertQuerysetEqual( 79 OuterB.objects.exclude(inner__isnull=False), 80 ['<OuterB: OuterB object>'] 81 ) -
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 1422 1429 self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, 1423 1430 can_reuse=can_reuse) 1424 1431