Ticket #12823: 12823_trunk.diff

File 12823_trunk.diff, 2.4 KB (added by PhiR_42, 5 years ago)

patch and test vs trunk

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

    diff -ur orig.trunk/django/db/models/sql/query.py trunk/django/db/models/sql/query.py
    old new  
    14431443        query.bump_prefix()
    14441444        query.clear_ordering(True)
    14451445        query.set_start(prefix)
    1446         self.add_filter(('%s__in' % prefix, query), negate=True, trim=True,
     1446        new_prefix = prefix.split(LOOKUP_SEP)[0]
     1447        self.add_filter(('%s__in' % new_prefix, query), negate=True, trim=True,
    14471448                can_reuse=can_reuse)
    14481449
    14491450        # If there's more than one join in the inner query (before any initial
  • trunk/tests/regressiontests/queries/tests.py

    diff -ur orig.trunk/tests/regressiontests/queries/tests.py trunk/tests/regressiontests/queries/tests.py
    old new  
    4242        n2 = Note.objects.create(note='n2', misc='bar', id=2)
    4343        self.n3 = Note.objects.create(note='n3', misc='foo', id=3)
    4444
    45         ann1 = Annotation.objects.create(name='a1', tag=self.t1)
     45        ann1 = Annotation.objects.create(name='a1', tag=self.t1, id=11)
    4646        ann1.notes.add(self.n1)
    47         ann2 = Annotation.objects.create(name='a2', tag=t4)
     47        ann2 = Annotation.objects.create(name='a2', tag=t4, id=12)
    4848        ann2.notes.add(n2, self.n3)
    4949
    5050        # Create these out of order so that sorting by 'id' will be different to sorting
    5151        # by 'info'. Helps detect some problems later.
    52         self.e2 = ExtraInfo.objects.create(info='e2', note=n2)
    53         e1 = ExtraInfo.objects.create(info='e1', note=self.n1)
     52        self.e2 = ExtraInfo.objects.create(info='e2', note=n2, id=22)
     53        e1 = ExtraInfo.objects.create(info='e1', note=self.n1, id=21)
    5454
    5555        self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
    5656        self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
     
    8080        Cover.objects.create(title="first", item=i4)
    8181        Cover.objects.create(title="second", item=self.i2)
    8282
     83    def test_ticket12823(self):
     84        self.assertQuerysetEqual(
     85            Author.objects.exclude(extra__note__annotation__name ='a2'),
     86            ['<Author: a1>', '<Author: a2>']
     87        )
     88       
    8389    def test_ticket1050(self):
    8490        self.assertQuerysetEqual(
    8591            Item.objects.filter(tags__isnull=True),
Back to Top