Ticket #15316: 15316_with_test.diff

File 15316_with_test.diff, 2.4 KB (added by Aleksandra Sendecka, 13 years ago)

patch with tests

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

     
    10751075                    can_reuse)
    10761076            return
    10771077
    1078         if (lookup_type == 'isnull' and value is True and not negate and
     1078        if (lookup_type == 'isnull' and not negate and
    10791079                len(join_list) > 1):
    10801080            # If the comparison is against NULL, we may need to use some left
    10811081            # outer joins when creating the join chain. This is only done when
  • tests/regressiontests/queries/tests.py

     
    1515    DumbCategory, ExtraInfo, Fan, Item, LeafA, LoopX, LoopZ, ManagedModel,
    1616    Member, NamedCategory, Note, Number, Plaything, PointerA, Ranking, Related,
    1717    Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, Node, ObjectA, ObjectB,
    18     ObjectC)
     18    ObjectC, CategoryItem)
    1919
    2020
    2121class BaseQuerysetTest(TestCase):
     
    10321032            []
    10331033        )
    10341034
     1035    def test_ticket15316(self):
     1036       c1 = NamedCategory(name="category1")
     1037       c2 = DumbCategory()
     1038       c1.save()
     1039       c2.save()
    10351040
     1041       ci1 = CategoryItem(category=c1)
     1042       ci2 = CategoryItem(category=c2)
     1043       ci1.save()
     1044       ci2.save()
     1045
     1046       self.assertEqual(
     1047           CategoryItem.objects.filter(category__namedcategory__isnull=False).count(),
     1048           1
     1049       )
     1050
    10361051class Queries5Tests(TestCase):
    10371052    def setUp(self):
    10381053        # Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the Meta.ordering
  • tests/regressiontests/queries/models.py

     
    1212class NamedCategory(DumbCategory):
    1313    name = models.CharField(max_length=10)
    1414
     15class CategoryItem(models.Model):
     16   category = models.ForeignKey(DumbCategory)
     17
     18   def __unicode__(self):
     19       return "category item: " + str(self.category)
     20
    1521class Tag(models.Model):
    1622    name = models.CharField(max_length=10)
    1723    parent = models.ForeignKey('self', blank=True, null=True,
Back to Top