Ticket #20487: 20487.diff
File 20487.diff, 3.6 KB (added by , 7 years ago) |
---|
-
tests/queries/models.py
diff --git a/tests/queries/models.py b/tests/queries/models.py index 902fd55c05..47edb0b017 100644
a b class CategoryItem(models.Model): 449 449 return "category item: " + str(self.category) 450 450 451 451 452 class OtherCategoryItem(models.Model): 453 Category = models.ForeignKey('SimpleCategory', models.CASCADE) 454 455 456 class CommonForeignKey(models.Model): 457 category = models.ForeignKey(CategoryItem, models.CASCADE) 458 other_category = models.ForeignKey(OtherCategoryItem, models.CASCADE) 459 460 452 461 class OneToOneCategory(models.Model): 453 462 new_name = models.CharField(max_length=15) 454 463 category = models.OneToOneField(SimpleCategory, models.CASCADE) -
tests/queries/tests.py
diff --git a/tests/queries/tests.py b/tests/queries/tests.py index ec50194e3a..1c3232f795 100644
a b from django.test.utils import CaptureQueriesContext 15 15 from .models import ( 16 16 FK1, Annotation, Article, Author, BaseA, Book, CategoryItem, 17 17 CategoryRelationship, Celebrity, Channel, Chapter, Child, ChildObjectA, 18 Classroom, Com pany, Cover, CustomPk, CustomPkTag, Detail, DumbCategory,19 Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Individual, Item, Job,20 JobResponsibilities, Join, LeafA, LeafB, LoopX, LoopZ, ManagedModel,21 Member, ModelA, ModelB, ModelC, ModelD, MyObject, NamedCategory, Node,22 N ote, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory,23 O rder, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program,24 P roxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related,25 RelatedIndividual, RelatedObject, Report, ReportComment, ReservedName,26 Re sponsibility, School, SharedConnection, SimpleCategory, SingleObject,27 S pecialCategory, Staff, StaffUser, Student, Tag, Task, Teacher,28 T icket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B,29 Ticket23605 C, TvChef, Valid, X,18 Classroom, CommonForeignKey, Company, Cover, CustomPk, CustomPkTag, Detail, 19 DumbCategory, Eaten, Employment, ExtraInfo, Fan, Food, Identifier, 20 Individual, Item, Job, JobResponsibilities, Join, LeafA, LeafB, LoopX, 21 LoopZ, ManagedModel, Member, ModelA, ModelB, ModelC, ModelD, MyObject, 22 NamedCategory, Node, Note, NullableName, Number, ObjectA, ObjectB, ObjectC, 23 OneToOneCategory, Order, OrderItem, OtherCategoryItem, Page, Paragraph, 24 Person, Plaything, PointerA, Program, ProxyCategory, ProxyObjectA, 25 ProxyObjectB, Ranking, Related, RelatedIndividual, RelatedObject, Report, 26 ReportComment, ReservedName, Responsibility, School, SharedConnection, 27 SimpleCategory, SingleObject, SpecialCategory, Staff, StaffUser, Student, 28 Tag, Task, Teacher, Ticket21203Child, Ticket21203Parent, Ticket23605A, 29 Ticket23605B, Ticket23605C, TvChef, Valid, X, 30 30 ) 31 31 32 32 … … class Queries1Tests(TestCase): 1172 1172 with self.assertRaisesMessage(FieldError, msg): 1173 1173 Tag.objects.filter(unknown_field__name='generic') 1174 1174 1175 def test_common_related_model(self): 1176 c1 = SimpleCategory.objects.create(name='c1') 1177 c2 = SimpleCategory.objects.create(name='c2') 1178 category = CategoryItem.objects.create(category=c1) 1179 other_category = OtherCategoryItem.objects.create(Category=c2) 1180 CommonForeignKey.objects.create(category=category, other_category=other_category) 1181 qs = CommonForeignKey.objects.values( 1182 'category', 'other_category', 'category__category', 'other_category__Category', 1183 ) 1184 self.assertTrue(qs[:20].exists()) 1185 1175 1186 1176 1187 class Queries2Tests(TestCase): 1177 1188 @classmethod