Ticket #12823: 12823_trunk.2.diff

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

updated (sorry for the username change)

  • django/db/models/sql/query.py

    diff -ur ./django/db/models/sql/query.py ../../patched_trunk//django/db/models/sql/query.py
    old new  
    15351535        alias, col = query.select[0]
    15361536        query.where.add((Constraint(alias, col, None), 'isnull', False), AND)
    15371537
    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,
    15391540                can_reuse=can_reuse)
    15401541
    15411542        # If there's more than one join in the inner query (before any initial
     
    15481549        active_positions = [pos for (pos, count) in
    15491550                enumerate(query.alias_refcount.itervalues()) if count]
    15501551        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,
    15521553                    trim=True, can_reuse=can_reuse)
    15531554
    15541555    def set_limits(self, low=None, high=None):
  • tests/regressiontests/queries/tests.py

    diff -ur ./tests/regressiontests/queries/tests.py ../../patched_trunk//tests/regressiontests/queries/tests.py
    old new  
    3636        n2 = Note.objects.create(note='n2', misc='bar', id=2)
    3737        self.n3 = Note.objects.create(note='n3', misc='foo', id=3)
    3838
    39         ann1 = Annotation.objects.create(name='a1', tag=self.t1)
     39        ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11)
    4040        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)
    4242        ann2.notes.add(n2, self.n3)
    4343
    4444        # Create these out of order so that sorting by 'id' will be different to sorting
    4545        # 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)
    4848
    4949        self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
    5050        self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
     
    7474        Cover.objects.create(title="first", item=i4)
    7575        Cover.objects.create(title="second", item=self.i2)
    7676
     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
    7784    def test_ticket1050(self):
    7885        self.assertQuerysetEqual(
    7986            Item.objects.filter(tags__isnull=True),
Back to Top