diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 8c34b50..40270c3 100644
a
|
b
|
class NullableName(models.Model):
|
357 | 357 | |
358 | 358 | class Meta: |
359 | 359 | ordering = ['id'] |
| 360 | |
| 361 | |
| 362 | class Base1(models.Model): |
| 363 | b1_id = models.AutoField(primary_key=True) |
| 364 | b1_desc = models.CharField(max_length=100, null=True) |
| 365 | |
| 366 | class Base2(models.Model): |
| 367 | b2_id = models.AutoField(primary_key=True) |
| 368 | b2_desc = models.CharField(max_length=100, null=True) |
| 369 | |
| 370 | class Base3(models.Model): |
| 371 | b3_id = models.AutoField(primary_key=True) |
| 372 | b3_desc = models.CharField(max_length=100, null=True) |
| 373 | |
| 374 | class Middle(Base1, Base2, Base3): |
| 375 | m_desc = models.CharField(max_length=100, null=True) |
| 376 | |
| 377 | class Top(Middle): |
| 378 | t_desc = models.CharField(max_length=100) |
diff --git a/tests/regressiontests/queries/tests.py b/tests/regressiontests/queries/tests.py
index 9bb3a29..d09e422 100644
a
|
b
|
from .models import (Annotation, Article, Author, Celebrity, Child, Cover,
|
23 | 23 | Ranking, Related, Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, |
24 | 24 | Node, ObjectA, ObjectB, ObjectC, CategoryItem, SimpleCategory, |
25 | 25 | SpecialCategory, OneToOneCategory, NullableName, ProxyCategory, |
26 | | SingleObject, RelatedObject) |
| 26 | SingleObject, RelatedObject, Top, Base1) |
27 | 27 | |
28 | 28 | |
29 | 29 | class BaseQuerysetTest(TestCase): |
… |
… |
class Queries1Tests(BaseQuerysetTest):
|
847 | 847 | ) |
848 | 848 | Tag._meta.ordering = original_ordering |
849 | 849 | |
| 850 | def test_ticket18174(self): |
| 851 | """ |
| 852 | Check that in a model like this: |
| 853 | / Base1 |
| 854 | Top -> Middle- Base2 |
| 855 | \ Base3 |
| 856 | |
| 857 | The joins are done from Top to Middle to Base1, Base2, Base3. |
| 858 | """ |
| 859 | Base1.objects.create() |
| 860 | Top.objects.create(t_desc='foo') |
| 861 | qs = Top.objects.all() |
| 862 | # The joins to the parent tables are added only when the query is |
| 863 | # evaluated. |
| 864 | results = list(qs) |
| 865 | self.assertEqual(qs.query.alias_map['queries_base1'].lhs_alias, 'queries_middle') |
| 866 | self.assertEqual(len(results), 1) |
| 867 | |
850 | 868 | def test_exclude(self): |
851 | 869 | self.assertQuerysetEqual( |
852 | 870 | Item.objects.exclude(tags__name='t4'), |