Ticket #12823: 12823_1.5.diff

File 12823_1.5.diff, 3.0 KB (added by PhiR_42, 10 years ago)

updated patch for django 1.5.5 (bug not fixed in this release)

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

    diff -ur ../Django-1.5.5/django/db/models/sql/query.py ./django/db/models/sql/query.py
    old new  
    15901590        alias, col = query.select[0]
    15911591        query.where.add((Constraint(alias, col, None), 'isnull', False), AND)
    15921592
    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,
    15941595                can_reuse=can_reuse)
    15951596
    15961597        # If there's more than one join in the inner query (before any initial
     
    16031604        active_positions = len([count for count
    16041605                                in query.alias_refcount.items() if count])
    16051606        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,
    16071608                    trim=True, can_reuse=can_reuse)
    16081609
    16091610    def set_limits(self, low=None, high=None):
  • tests/regressiontests/queries/tests.py

    diff -ur ../Django-1.5.5/tests/regressiontests/queries/tests.py ./tests/regressiontests/queries/tests.py
    old new  
    4545        n2 = Note.objects.create(note='n2', misc='bar', id=2)
    4646        self.n3 = Note.objects.create(note='n3', misc='foo', id=3)
    4747
    48         ann1 = Annotation.objects.create(name='a1', tag=self.t1)
     48        ann1 = Annotation.objects.create(name='a1', tag=self.t1, id = 11)
    4949        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)
    5151        ann2.notes.add(n2, self.n3)
    5252
    5353        # Create these out of order so that sorting by 'id' will be different to sorting
    5454        # 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)
    5757
    5858        self.a1 = Author.objects.create(name='a1', num=1001, extra=e1)
    5959        self.a2 = Author.objects.create(name='a2', num=2002, extra=e1)
     
    8383        Cover.objects.create(title="first", item=i4)
    8484        Cover.objects.create(title="second", item=self.i2)
    8585
     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
    8693    def test_ticket1050(self):
    8794        self.assertQuerysetEqual(
    8895            Item.objects.filter(tags__isnull=True),
Back to Top