Ticket #19672: 19672.diff

File 19672.diff, 3.1 KB (added by Erin Kelly, 12 years ago)
  • django/db/models/sql/query.py

    diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
    index 613f4c4..c2c3d7a 100644
    a b class Query(object):  
    12291229            self.promote_joins(join_list)
    12301230            if lookup_type != 'isnull':
    12311231                if len(join_list) > 1:
    1232                     for alias in join_list:
    1233                         if self.alias_map[alias].join_type == self.LOUTER:
    1234                             j_col = self.alias_map[alias].rhs_join_col
     1232                    for j_alias in join_list:
     1233                        if self.alias_map[j_alias].join_type == self.LOUTER:
     1234                            j_col = self.alias_map[j_alias].rhs_join_col
    12351235                            # The join promotion logic should never produce
    12361236                            # a LOUTER join for the base join - assert that.
    12371237                            assert j_col is not None
    12381238                            entry = self.where_class()
    12391239                            entry.add(
    1240                                 (Constraint(alias, j_col, None), 'isnull', True),
     1240                                (Constraint(j_alias, j_col, None), 'isnull', True),
    12411241                                AND
    12421242                            )
    12431243                            entry.negate()
  • tests/regressiontests/queries/models.py

    diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
    index 16583e8..5bccb49 100644
    a b class Annotation(models.Model):  
    6464class ExtraInfo(models.Model):
    6565    info = models.CharField(max_length=100)
    6666    note = models.ForeignKey(Note)
     67    value = models.IntegerField(null=True)
    6768
    6869    class Meta:
    6970        ordering = ['info']
  • tests/regressiontests/queries/tests.py

    diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
    index 4adf076..272b692 100644
    a b class Queries1Tests(BaseQuerysetTest):  
    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)
    56         e1 = ExtraInfo.objects.create(info='e1', note=self.n1)
     55        self.e2 = ExtraInfo.objects.create(info='e2', note=n2, value=41)
     56        e1 = ExtraInfo.objects.create(info='e1', note=self.n1, value=42)
    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)
    class Queries1Tests(BaseQuerysetTest):  
    11061106        self.assertTrue(str(q3.query).count('LEFT OUTER JOIN') == 1)
    11071107        self.assertTrue(str(q3.query).count('INNER JOIN') == 0)
    11081108
     1109    def test_ticket19672(self):
     1110        self.assertQuerysetEqual(
     1111            Report.objects.filter(Q(creator__isnull=False)&
     1112                                  ~Q(creator__extra__value=41)),
     1113            ['<Report: r1>']
     1114        )
     1115
    11091116
    11101117class Queries2Tests(TestCase):
    11111118    def setUp(self):
Back to Top