Ticket #12240: django-12240.diff

File django-12240.diff, 2.2 KB (added by embe, 6 years ago)
  • django/db/models/sql/query.py

     
    14361436                next = requested.get(f.name, {})
    14371437            else:
    14381438                next = False
    1439             if f.null is not None:
    1440                 new_nullable = f.null
    1441             else:
    1442                 new_nullable = None
    14431439            for dupe_opts, dupe_col in dupe_set:
    14441440                self.update_dupe_avoidance(dupe_opts, dupe_col, alias)
    14451441            self.fill_related_selections(f.rel.to._meta, alias, cur_depth + 1,
    1446                     used, next, restricted, new_nullable, dupe_set, avoid)
     1442                    used, next, restricted, promote, dupe_set, avoid)
    14471443
    14481444    def add_aggregate(self, aggregate, model, alias, is_summary):
    14491445        """
  • tests/regressiontests/null_fk/models.py

     
    44
    55from django.db import models
    66
     7class SystemDetails(models.Model):
     8    details = models.CharField(max_length=32)
     9
    710class SystemInfo(models.Model):
     11    system_details = models.ForeignKey(SystemDetails)
    812    system_name = models.CharField(max_length=32)
    913
    1014class Forum(models.Model):
     
    3034
    3135__test__ = {'API_TESTS':"""
    3236
    33 >>> s = SystemInfo.objects.create(system_name='First forum')
     37>>> d = SystemDetails.objects.create(details='First details')
     38>>> s = SystemInfo.objects.create(system_details=d, system_name='First forum')
    3439>>> f = Forum.objects.create(system_info=s, forum_name='First forum')
    3540>>> p = Post.objects.create(forum=f, title='First Post')
    3641>>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
     
    5560>>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post is None
    5661True
    5762
     63# Regression test for #12240.
     64>>> comments = Comment.objects.select_related('post__forum__system_info__system_details').all()
     65>>> [(c.id, c.comment_text, c.post) for c in comments]
     66[(1, u'My first comment', <Post: First Post>), (2, u'My second comment', None)]
     67
    5868"""}
Back to Top