Ticket #12240: django-12240.diff
File django-12240.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/db/models/sql/query.py
1436 1436 next = requested.get(f.name, {}) 1437 1437 else: 1438 1438 next = False 1439 if f.null is not None:1440 new_nullable = f.null1441 else:1442 new_nullable = None1443 1439 for dupe_opts, dupe_col in dupe_set: 1444 1440 self.update_dupe_avoidance(dupe_opts, dupe_col, alias) 1445 1441 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) 1447 1443 1448 1444 def add_aggregate(self, aggregate, model, alias, is_summary): 1449 1445 """ -
tests/regressiontests/null_fk/models.py
4 4 5 5 from django.db import models 6 6 7 class SystemDetails(models.Model): 8 details = models.CharField(max_length=32) 9 7 10 class SystemInfo(models.Model): 11 system_details = models.ForeignKey(SystemDetails) 8 12 system_name = models.CharField(max_length=32) 9 13 10 14 class Forum(models.Model): … … 30 34 31 35 __test__ = {'API_TESTS':""" 32 36 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') 34 39 >>> f = Forum.objects.create(system_info=s, forum_name='First forum') 35 40 >>> p = Post.objects.create(forum=f, title='First Post') 36 41 >>> c1 = Comment.objects.create(post=p, comment_text='My first comment') … … 55 60 >>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post is None 56 61 True 57 62 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 58 68 """}