diff -ur ./django/db/models/sql/query.py ../../patched_trunk//django/db/models/sql/query.py
old
|
new
|
|
1535 | 1535 | alias, col = query.select[0] |
1536 | 1536 | query.where.add((Constraint(alias, col, None), 'isnull', False), AND) |
1537 | 1537 | |
1538 | | self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, |
| 1538 | new_prefix = prefix.split(LOOKUP_SEP)[0] |
| 1539 | self.add_filter(('%s__in' % new_prefix, query), negate=True, trim=True, |
1539 | 1540 | can_reuse=can_reuse) |
1540 | 1541 | |
1541 | 1542 | # If there's more than one join in the inner query (before any initial |
… |
… |
|
1548 | 1549 | active_positions = [pos for (pos, count) in |
1549 | 1550 | enumerate(query.alias_refcount.itervalues()) if count] |
1550 | 1551 | if active_positions[-1] > 1: |
1551 | | self.add_filter(('%s__isnull' % prefix, False), negate=True, |
| 1552 | self.add_filter(('%s__isnull' % new_prefix, False), negate=True, |
1552 | 1553 | trim=True, can_reuse=can_reuse) |
1553 | 1554 | |
1554 | 1555 | def set_limits(self, low=None, high=None): |
diff -ur ./tests/regressiontests/queries/tests.py ../../patched_trunk//tests/regressiontests/queries/tests.py
old
|
new
|
|
36 | 36 | n2 = Note.objects.create(note='n2', misc='bar', id=2) |
37 | 37 | self.n3 = Note.objects.create(note='n3', misc='foo', id=3) |
38 | 38 | |
39 | | ann1 = Annotation.objects.create(name='a1', tag=self.t1) |
| 39 | ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11) |
40 | 40 | ann1.notes.add(self.n1) |
41 | | ann2 = Annotation.objects.create(name='a2', tag=t4) |
| 41 | ann2 = Annotation.objects.create(name='a2', tag=t4, id=12) |
42 | 42 | ann2.notes.add(n2, self.n3) |
43 | 43 | |
44 | 44 | # Create these out of order so that sorting by 'id' will be different to sorting |
45 | 45 | # by 'info'. Helps detect some problems later. |
46 | | self.e2 = ExtraInfo.objects.create(info='e2', note=n2) |
47 | | e1 = ExtraInfo.objects.create(info='e1', note=self.n1) |
| 46 | self.e2 = ExtraInfo.objects.create(info='e2', note=n2, id=21) |
| 47 | e1 = ExtraInfo.objects.create(info='e1', note=self.n1, id=22) |
48 | 48 | |
49 | 49 | self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) |
50 | 50 | self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) |
… |
… |
|
74 | 74 | Cover.objects.create(title="first", item=i4) |
75 | 75 | Cover.objects.create(title="second", item=self.i2) |
76 | 76 | |
| 77 | def test_ticket12823(self): |
| 78 | #self.assertEqual(str(Author.objects.exclude(extra__note__annotation__name ='a2').query), "") |
| 79 | self.assertQuerysetEqual( |
| 80 | Author.objects.exclude(extra__note__annotation__name ='a2'), |
| 81 | ['<Author: a1>', '<Author: a2>'] |
| 82 | ) |
| 83 | |
77 | 84 | def test_ticket1050(self): |
78 | 85 | self.assertQuerysetEqual( |
79 | 86 | Item.objects.filter(tags__isnull=True), |