Ticket #12823: 12823_trunk.2.2.diff
File 12823_trunk.2.2.diff, 2.9 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/queries/tests.py
39 39 n2 = Note.objects.create(note='n2', misc='bar', id=2) 40 40 self.n3 = Note.objects.create(note='n3', misc='foo', id=3) 41 41 42 ann1 = Annotation.objects.create(name='a1', tag=self.t1 )42 ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11) 43 43 ann1.notes.add(self.n1) 44 ann2 = Annotation.objects.create(name='a2', tag=t4 )44 ann2 = Annotation.objects.create(name='a2', tag=t4, id=12) 45 45 ann2.notes.add(n2, self.n3) 46 46 47 47 # Create these out of order so that sorting by 'id' will be different to sorting 48 48 # by 'info'. Helps detect some problems later. 49 self.e2 = ExtraInfo.objects.create(info='e2', note=n2 )50 e1 = ExtraInfo.objects.create(info='e1', note=self.n1 )49 self.e2 = ExtraInfo.objects.create(info='e2', note=n2, id=21) 50 e1 = ExtraInfo.objects.create(info='e1', note=self.n1, id=22) 51 51 52 52 self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) 53 53 self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) … … 77 77 Cover.objects.create(title="first", item=i4) 78 78 Cover.objects.create(title="second", item=self.i2) 79 79 80 def test_ticket12823(self): 81 #self.assertEqual(str(Author.objects.exclude(extra__note__annotation__name ='a2').query), "") 82 self.assertQuerysetEqual( 83 Author.objects.exclude(extra__note__annotation__name ='a2'), 84 ['<Author: a1>', '<Author: a2>'] 85 ) 86 80 87 def test_ticket1050(self): 81 88 self.assertQuerysetEqual( 82 89 Item.objects.filter(tags__isnull=True), -
django/db/models/sql/query.py
1551 1551 alias, col = query.select[0] 1552 1552 query.where.add((Constraint(alias, col, None), 'isnull', False), AND) 1553 1553 1554 self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, 1554 new_prefix = prefix.split(LOOKUP_SEP)[0] 1555 self.add_filter(('%s__in' % new_prefix, query), negate=True, trim=True, 1555 1556 can_reuse=can_reuse) 1556 1557 1557 1558 # If there's more than one join in the inner query (before any initial … … 1564 1565 active_positions = [pos for (pos, count) in 1565 1566 enumerate(query.alias_refcount.itervalues()) if count] 1566 1567 if active_positions[-1] > 1: 1567 self.add_filter(('%s__isnull' % prefix, False), negate=True,1568 self.add_filter(('%s__isnull' % new_prefix, False), negate=True, 1568 1569 trim=True, can_reuse=can_reuse) 1569 1570 1570 1571 def set_limits(self, low=None, high=None):