diff -ur ../orig/Django-1.2.5//django/db/models/sql/query.py ./django/db/models/sql/query.py
old
|
new
|
|
1481 | 1481 | alias, col = query.select[0] |
1482 | 1482 | query.where.add((Constraint(alias, col, None), 'isnull', False), AND) |
1483 | 1483 | |
1484 | | self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, |
| 1484 | new_prefix = prefix.split(LOOKUP_SEP)[0] |
| 1485 | self.add_filter(('%s__in' % new_prefix, query), negate=True, trim=True, |
1485 | 1486 | can_reuse=can_reuse) |
1486 | 1487 | |
1487 | 1488 | # If there's more than one join in the inner query (before any initial |
… |
… |
|
1494 | 1495 | active_positions = [pos for (pos, count) in |
1495 | 1496 | enumerate(query.alias_refcount.itervalues()) if count] |
1496 | 1497 | if active_positions[-1] > 1: |
1497 | | self.add_filter(('%s__isnull' % prefix, False), negate=True, |
| 1498 | self.add_filter(('%s__isnull' % new_prefix, False), negate=True, |
1498 | 1499 | trim=True, can_reuse=can_reuse) |
1499 | 1500 | |
1500 | 1501 | def set_limits(self, low=None, high=None): |
diff -ur ../orig/Django-1.2.5//tests/regressiontests/queries/tests.py ./tests/regressiontests/queries/tests.py
old
|
new
|
|
48 | 48 | n2 = Note.objects.create(note='n2', misc='bar', id=2) |
49 | 49 | self.n3 = Note.objects.create(note='n3', misc='foo', id=3) |
50 | 50 | |
51 | | ann1 = Annotation.objects.create(name='a1', tag=self.t1) |
| 51 | ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11) |
52 | 52 | ann1.notes.add(self.n1) |
53 | | ann2 = Annotation.objects.create(name='a2', tag=t4) |
| 53 | ann2 = Annotation.objects.create(name='a2', tag=t4, id=12) |
54 | 54 | ann2.notes.add(n2, self.n3) |
55 | 55 | |
56 | 56 | # Create these out of order so that sorting by 'id' will be different to sorting |
57 | 57 | # by 'info'. Helps detect some problems later. |
58 | | self.e2 = ExtraInfo.objects.create(info='e2', note=n2) |
59 | | e1 = ExtraInfo.objects.create(info='e1', note=self.n1) |
| 58 | self.e2 = ExtraInfo.objects.create(info='e2', note=n2, id=21) |
| 59 | e1 = ExtraInfo.objects.create(info='e1', note=self.n1, id=22) |
60 | 60 | |
61 | 61 | self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) |
62 | 62 | self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) |
… |
… |
|
86 | 86 | Cover.objects.create(title="first", item=i4) |
87 | 87 | Cover.objects.create(title="second", item=self.i2) |
88 | 88 | |
| 89 | def test_ticket12823(self): |
| 90 | #self.assertEqual(str(Author.objects.exclude(extra__note__annotation__name ='a2').query), "") |
| 91 | self.assertQuerysetEqual( |
| 92 | Author.objects.exclude(extra__note__annotation__name ='a2'), |
| 93 | ['<Author: a1>', '<Author: a2>'] |
| 94 | ) |
| 95 | |
89 | 96 | def test_ticket1050(self): |
90 | 97 | self.assertQuerysetEqual( |
91 | 98 | Item.objects.filter(tags__isnull=True), |