diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
index d02adcc..444649a 100644
a
|
b
|
class SimpleItem(models.Model):
|
52 | 52 | class Feature(models.Model): |
53 | 53 | item = models.ForeignKey(SimpleItem) |
54 | 54 | |
| 55 | class SpecialFeature(models.Model): |
| 56 | feature = models.ForeignKey(Feature) |
| 57 | |
55 | 58 | class ItemAndSimpleItem(models.Model): |
56 | 59 | item = models.ForeignKey(Item) |
57 | 60 | simple = models.ForeignKey(SimpleItem) |
diff --git a/tests/regressiontests/defer_regress/tests.py b/tests/regressiontests/defer_regress/tests.py
index 53bb59f..adc6966 100644
a
|
b
|
from django.db.models.loading import cache
|
9 | 9 | from django.test import TestCase |
10 | 10 | |
11 | 11 | from .models import (ResolveThis, Item, RelatedItem, Child, Leaf, Proxy, |
12 | | SimpleItem, Feature, ItemAndSimpleItem) |
| 12 | SimpleItem, Feature, ItemAndSimpleItem, SpecialFeature) |
13 | 13 | |
14 | 14 | |
15 | 15 | class DeferRegressionTest(TestCase): |
… |
… |
class DeferRegressionTest(TestCase):
|
115 | 115 | RelatedItem, |
116 | 116 | ResolveThis, |
117 | 117 | SimpleItem, |
| 118 | SpecialFeature, |
118 | 119 | ] |
119 | 120 | ) |
120 | 121 | |
… |
… |
class DeferRegressionTest(TestCase):
|
152 | 153 | "RelatedItem_Deferred_item_id", |
153 | 154 | "ResolveThis", |
154 | 155 | "SimpleItem", |
| 156 | "SpecialFeature", |
155 | 157 | ] |
156 | 158 | ) |
157 | 159 | |
… |
… |
class DeferRegressionTest(TestCase):
|
197 | 199 | self.assertEqual(obj.item, item2) |
198 | 200 | self.assertEqual(obj.item_id, item2.id) |
199 | 201 | |
| 202 | def test_only_with_select_related(self): |
| 203 | item = SimpleItem.objects.create(name='first', value=47) |
| 204 | feature = Feature.objects.create(item=item) |
| 205 | special_feature = SpecialFeature.objects.create(feature=feature) |
| 206 | |
| 207 | qs = Feature.objects.only('item__name').select_related('item__name') |
| 208 | self.assertEqual(len(qs), 1) |
| 209 | |
| 210 | qs = SpecialFeature.objects.only('feature__item__name').select_related('feature__item__name') |
| 211 | self.assertEqual(len(qs), 1) |
| 212 | |
200 | 213 | def test_deferred_class_factory(self): |
201 | 214 | from django.db.models.query_utils import deferred_class_factory |
202 | 215 | new_class = deferred_class_factory(Item, |