diff --git a/tests/regressiontests/select_related_regress/models.py b/tests/regressiontests/select_related_regress/models.py
index a291a54..620b8eb 100644
a
|
b
|
class Item(models.Model):
|
94 | 94 | |
95 | 95 | def __str__(self): |
96 | 96 | return self.name |
| 97 | |
| 98 | # Models for testing bug #19870. |
| 99 | @python_2_unicode_compatible |
| 100 | class Fowl(models.Model): |
| 101 | name = models.CharField(max_length=10) |
| 102 | |
| 103 | def __str__(self): |
| 104 | return self.name |
| 105 | |
| 106 | class Hen(Fowl): |
| 107 | pass |
| 108 | |
| 109 | class Chick(Fowl): |
| 110 | mother = models.ForeignKey(Hen) |
diff --git a/tests/regressiontests/select_related_regress/tests.py b/tests/regressiontests/select_related_regress/tests.py
index 0e27d07..f6d21b2 100644
a
|
b
|
from django.utils import six
|
5 | 5 | |
6 | 6 | from .models import (Building, Child, Device, Port, Item, Country, Connection, |
7 | 7 | ClientStatus, State, Client, SpecialClient, TUser, Person, Student, |
8 | | Organizer, Class, Enrollment) |
| 8 | Organizer, Class, Enrollment, Hen, Chick) |
9 | 9 | |
10 | 10 | |
11 | 11 | class SelectRelatedRegressTests(TestCase): |
… |
… |
class SelectRelatedRegressTests(TestCase):
|
162 | 162 | # The select_related join was promoted as there is already an |
163 | 163 | # existing join. |
164 | 164 | self.assertTrue('LEFT OUTER' in str(qs.query)) |
| 165 | |
| 166 | def test_regression_19870(self): |
| 167 | """ |
| 168 | Regression for #19870 |
| 169 | |
| 170 | """ |
| 171 | hen = Hen.objects.create(name='Hen') |
| 172 | chick = Chick.objects.create(name='Chick', mother=hen) |
| 173 | |
| 174 | self.assertEqual(Chick.objects.all()[0].mother.name, 'Hen') |
| 175 | self.assertEqual(Chick.objects.select_related()[0].mother.name, 'Hen') |