Ticket #9926: 2008-12-29-select-related-subclass-null.patch

File 2008-12-29-select-related-subclass-null.patch, 1.7 KB (added by Adam Gomaa, 16 years ago)
  • tests/regressiontests/queries/models.py

    diff -r 0354c968050b tests/regressiontests/queries/models.py
    a b try:  
    1616except NameError:
    1717    from django.utils.itercompat import sorted
    1818
     19class DumbCategory(models.Model):
     20    pass
     21
     22class NamedCategory(DumbCategory):
     23    name = models.CharField(max_length=10)
     24
    1925class Tag(models.Model):
    2026    name = models.CharField(max_length=10)
    2127    parent = models.ForeignKey('self', blank=True, null=True,
    2228            related_name='children')
     29    category = models.ForeignKey(NamedCategory, null=True, default=None)
    2330
    2431    class Meta:
    2532        ordering = ['name']
    class PointerB(models.Model):  
    240247
    241248
    242249__test__ = {'API_TESTS':"""
    243 >>> t1 = Tag.objects.create(name='t1')
    244 >>> t2 = Tag.objects.create(name='t2', parent=t1)
     250>>> generic = NamedCategory.objects.create(name="Generic")
     251>>> t1 = Tag.objects.create(name='t1', category=generic)
     252>>> t2 = Tag.objects.create(name='t2', parent=t1, category=generic)
    245253>>> t3 = Tag.objects.create(name='t3', parent=t1)
    246254>>> t4 = Tag.objects.create(name='t4', parent=t3)
    247255>>> t5 = Tag.objects.create(name='t5', parent=t3)
    Bug #6981  
    700708>>> Tag.objects.select_related('parent').order_by('name')
    701709[<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>]
    702710
     711Bug #TBD
     712>>> Tag.objects.select_related('parent', "category").order_by('name')
     713[<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>]
     714>>> Tag.objects.select_related('parent', "parent__category").order_by('name')
     715[<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>]
     716
    703717Bug #6180, #6203 -- dates with limits and/or counts
    704718>>> Item.objects.count()
    7057194
Back to Top