diff -ur ../Django-1.5.5/django/db/models/sql/query.py ./django/db/models/sql/query.py
old
|
new
|
|
1590 | 1590 | alias, col = query.select[0] |
1591 | 1591 | query.where.add((Constraint(alias, col, None), 'isnull', False), AND) |
1592 | 1592 | |
1593 | | self.add_filter(('%s__in' % prefix, query), negate=True, trim=True, |
| 1593 | new_prefix = prefix.split(LOOKUP_SEP)[0] |
| 1594 | self.add_filter(('%s__in' % new_prefix, query), negate=True, trim=True, |
1594 | 1595 | can_reuse=can_reuse) |
1595 | 1596 | |
1596 | 1597 | # If there's more than one join in the inner query (before any initial |
… |
… |
|
1603 | 1604 | active_positions = len([count for count |
1604 | 1605 | in query.alias_refcount.items() if count]) |
1605 | 1606 | if active_positions > 1: |
1606 | | self.add_filter(('%s__isnull' % prefix, False), negate=True, |
| 1607 | self.add_filter(('%s__isnull' % new_prefix, False), negate=True, |
1607 | 1608 | trim=True, can_reuse=can_reuse) |
1608 | 1609 | |
1609 | 1610 | def set_limits(self, low=None, high=None): |
diff -ur ../Django-1.5.5/tests/regressiontests/queries/tests.py ./tests/regressiontests/queries/tests.py
old
|
new
|
|
45 | 45 | n2 = Note.objects.create(note='n2', misc='bar', id=2) |
46 | 46 | self.n3 = Note.objects.create(note='n3', misc='foo', id=3) |
47 | 47 | |
48 | | ann1 = Annotation.objects.create(name='a1', tag=self.t1) |
| 48 | ann1 = Annotation.objects.create(name='a1', tag=self.t1, id = 11) |
49 | 49 | ann1.notes.add(self.n1) |
50 | | ann2 = Annotation.objects.create(name='a2', tag=t4) |
| 50 | ann2 = Annotation.objects.create(name='a2', tag=t4, id = 12) |
51 | 51 | ann2.notes.add(n2, self.n3) |
52 | 52 | |
53 | 53 | # Create these out of order so that sorting by 'id' will be different to sorting |
54 | 54 | # by 'info'. Helps detect some problems later. |
55 | | self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41) |
56 | | e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42) |
| 55 | self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41, id = 21) |
| 56 | e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42, id = 22) |
57 | 57 | |
58 | 58 | self.a1 = Author.objects.create(name='a1', num=1001, extra=e1) |
59 | 59 | self.a2 = Author.objects.create(name='a2', num=2002, extra=e1) |
… |
… |
|
83 | 83 | Cover.objects.create(title="first", item=i4) |
84 | 84 | Cover.objects.create(title="second", item=self.i2) |
85 | 85 | |
| 86 | def test_ticket12823(self): |
| 87 | #self.assertEqual(str(Author.objects.exclude(extra__note__annotation__name ='a2').query), "") |
| 88 | self.assertQuerysetEqual( |
| 89 | Author.objects.exclude(extra__note__annotation__name ='a2'), |
| 90 | ['<Author: a1>', '<Author: a2>'] |
| 91 | ) |
| 92 | |
86 | 93 | def test_ticket1050(self): |
87 | 94 | self.assertQuerysetEqual( |
88 | 95 | Item.objects.filter(tags__isnull=True), |