summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2010-03-08 12:47:16 +0000
committerLuke Plant <L.Plant.98@cantab.net>2010-03-08 12:47:16 +0000
commit5e3a2e2f3956f358b5e82e217c20bb0b36fb0665 (patch)
tree106f3a359a5746bcc76d06cf7a001fa502c13102 /tests/regressiontests
parent40c022c91e8f5176a01a23c6dac8d938b8fa3a93 (diff)
Fixed #12240 - select_related doesn't work correctly when mixing nullable and non-nullable keys
Thanks to embe for report and Alex for fix. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12719 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/null_fk/models.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/regressiontests/null_fk/models.py b/tests/regressiontests/null_fk/models.py
index 49887819ac..1f191daaad 100644
--- a/tests/regressiontests/null_fk/models.py
+++ b/tests/regressiontests/null_fk/models.py
@@ -4,7 +4,11 @@ Regression tests for proper working of ForeignKey(null=True).
from django.db import models
+class SystemDetails(models.Model):
+ details = models.TextField()
+
class SystemInfo(models.Model):
+ system_details = models.ForeignKey(SystemDetails)
system_name = models.CharField(max_length=32)
class Forum(models.Model):
@@ -30,7 +34,8 @@ class Comment(models.Model):
__test__ = {'API_TESTS':"""
->>> s = SystemInfo.objects.create(system_name='First forum')
+>>> d = SystemDetails.objects.create(details='First details')
+>>> s = SystemInfo.objects.create(system_name='First forum', system_details=d)
>>> f = Forum.objects.create(system_info=s, forum_name='First forum')
>>> p = Post.objects.create(forum=f, title='First Post')
>>> c1 = Comment.objects.create(post=p, comment_text='My first comment')
@@ -55,4 +60,8 @@ None
>>> Comment.objects.select_related('post').filter(post__isnull=True)[0].post is None
True
+>>> comments = Comment.objects.select_related('post__forum__system_info__system_details')
+>>> [(c.id, c.comment_text, c.post) for c in comments]
+[(1, u'My first comment', <Post: First Post>), (2, u'My second comment', None)]
+
"""}