1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #28101 -- Fixed a regression with nested __in subquery lookups and to_field.

Thanks Kristian Klette for the report and Tim for the help.
This commit is contained in:
Simon Charette
2017-04-22 17:04:02 -04:00
parent 3f1ba76851
commit 8ef35468b6
4 changed files with 26 additions and 6 deletions

View File

@@ -22,11 +22,11 @@ from .models import (
Note, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory,
Order, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program,
ProxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related,
RelatedIndividual, RelatedObject, Report, ReservedName, Responsibility,
School, SharedConnection, SimpleCategory, SingleObject, SpecialCategory,
Staff, StaffUser, Student, Tag, Task, Teacher, Ticket21203Child,
Ticket21203Parent, Ticket23605A, Ticket23605B, Ticket23605C, TvChef, Valid,
X,
RelatedIndividual, RelatedObject, Report, ReportComment, ReservedName,
Responsibility, School, SharedConnection, SimpleCategory, SingleObject,
SpecialCategory, Staff, StaffUser, Student, Tag, Task, Teacher,
Ticket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B,
Ticket23605C, TvChef, Valid, X,
)
@@ -2406,6 +2406,18 @@ class ToFieldTests(TestCase):
{apple}
)
def test_nested_in_subquery(self):
extra = ExtraInfo.objects.create()
author = Author.objects.create(num=42, extra=extra)
report = Report.objects.create(creator=author)
comment = ReportComment.objects.create(report=report)
comments = ReportComment.objects.filter(
report__in=Report.objects.filter(
creator__in=extra.author_set.all(),
),
)
self.assertSequenceEqual(comments, [comment])
def test_reverse_in(self):
apple = Food.objects.create(name="apple")
pear = Food.objects.create(name="pear")