Ticket #12823: 12823_trunk.2.2.diff

File 12823_trunk.2.2.diff, 2.9 KB (added by Philippe Raoult, 13 years ago)

Updated for current trunk

  • tests/regressiontests/queries/tests.py

     
    3939        n2 = Note.objects.create(note='n2', misc='bar', id=2)
    4040        self.n3 = Note.objects.create(note='n3', misc='foo', id=3)
    4141
    42         ann1 = Annotation.objects.create(name='a1', tag=self.t1)
     42        ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11)
    4343        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)
    4545        ann2.notes.add(n2, self.n3)
    4646
    4747        # Create these out of order so that sorting by 'id' will be different to sorting
    4848        # 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)
    5151
    5252        self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
    5353        self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
     
    7777        Cover.objects.create(title="first", item=i4)
    7878        Cover.objects.create(title="second", item=self.i2)
    7979
     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
    8087    def test_ticket1050(self):
    8188        self.assertQuerysetEqual(
    8289            Item.objects.filter(tags__isnull=True),
  • django/db/models/sql/query.py

     
    15511551        alias, col = query.select[0]
    15521552        query.where.add((Constraint(alias, col, None), 'isnull', False), AND)
    15531553
    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,
    15551556                can_reuse=can_reuse)
    15561557
    15571558        # If there's more than one join in the inner query (before any initial
     
    15641565        active_positions = [pos for (pos, count) in
    15651566                enumerate(query.alias_refcount.itervalues()) if count]
    15661567        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,
    15681569                    trim=True, can_reuse=can_reuse)
    15691570
    15701571    def set_limits(self, low=None, high=None):
Back to Top