Ticket #12823: 12823_1.2.diff

File 12823_1.2.diff, 3.0 KB (added by Philippe Raoult, 13 years ago)
  • django/db/models/sql/query.py

    diff -ur ../orig/Django-1.2.5//django/db/models/sql/query.py ./django/db/models/sql/query.py
    old new  
    14811481        alias, col = query.select[0]
    14821482        query.where.add((Constraint(alias, col, None), 'isnull', False), AND)
    14831483
    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,
    14851486                can_reuse=can_reuse)
    14861487
    14871488        # If there's more than one join in the inner query (before any initial
     
    14941495        active_positions = [pos for (pos, count) in
    14951496                enumerate(query.alias_refcount.itervalues()) if count]
    14961497        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,
    14981499                    trim=True, can_reuse=can_reuse)
    14991500
    15001501    def set_limits(self, low=None, high=None):
  • tests/regressiontests/queries/tests.py

    diff -ur ../orig/Django-1.2.5//tests/regressiontests/queries/tests.py ./tests/regressiontests/queries/tests.py
    old new  
    4848        n2 = Note.objects.create(note='n2', misc='bar', id=2)
    4949        self.n3 = Note.objects.create(note='n3', misc='foo', id=3)
    5050
    51         ann1 = Annotation.objects.create(name='a1', tag=self.t1)
     51        ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11)
    5252        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)
    5454        ann2.notes.add(n2, self.n3)
    5555
    5656        # Create these out of order so that sorting by 'id' will be different to sorting
    5757        # 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)
    6060
    6161        self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
    6262        self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
     
    8686        Cover.objects.create(title="first", item=i4)
    8787        Cover.objects.create(title="second", item=self.i2)
    8888
     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
    8996    def test_ticket1050(self):
    9097        self.assertQuerysetEqual(
    9198            Item.objects.filter(tags__isnull=True),
Back to Top