mirror of
https://github.com/django/django.git
synced 2025-10-28 08:06:09 +00:00
[1.8.x] Fixed #24605 -- Fixed incorrect reference to alias in subquery.
Thanks to charettes and priidukull for investigating the issue, and to
kurevin for the report.
Backport of 355c5edd93 from master
This commit is contained in:
committed by
Tim Graham
parent
1e594b257e
commit
581afddc77
@@ -23,16 +23,16 @@ from .models import (
|
||||
FK1, X, Annotation, Article, Author, BaseA, Book, CategoryItem,
|
||||
CategoryRelationship, Celebrity, Channel, Chapter, Child, ChildObjectA,
|
||||
Classroom, Company, Cover, CustomPk, CustomPkTag, Detail, DumbCategory,
|
||||
Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Item, Job,
|
||||
Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Individual, Item, Job,
|
||||
JobResponsibilities, Join, LeafA, LeafB, LoopX, LoopZ, ManagedModel,
|
||||
Member, ModelA, ModelB, ModelC, ModelD, MyObject, NamedCategory, Node,
|
||||
Note, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory,
|
||||
Order, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program,
|
||||
ProxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related, RelatedObject,
|
||||
Report, ReservedName, Responsibility, School, SharedConnection,
|
||||
SimpleCategory, SingleObject, SpecialCategory, Staff, StaffUser, Student,
|
||||
Tag, Task, Ticket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B,
|
||||
Ticket23605C, TvChef, Valid,
|
||||
ProxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related,
|
||||
RelatedIndividual, RelatedObject, Report, ReservedName, Responsibility,
|
||||
School, SharedConnection, SimpleCategory, SingleObject, SpecialCategory,
|
||||
Staff, StaffUser, Student, Tag, Task, Ticket21203Child, Ticket21203Parent,
|
||||
Ticket23605A, Ticket23605B, Ticket23605C, TvChef, Valid,
|
||||
)
|
||||
|
||||
|
||||
@@ -3693,3 +3693,27 @@ class Ticket23605Tests(TestCase):
|
||||
self.assertQuerysetEqual(qs1, [a1], lambda x: x)
|
||||
qs2 = Ticket23605A.objects.exclude(complex_q)
|
||||
self.assertQuerysetEqual(qs2, [a2], lambda x: x)
|
||||
|
||||
|
||||
class TestTicket24605(TestCase):
|
||||
def test_ticket_24605(self):
|
||||
"""
|
||||
Subquery table names should be quoted.
|
||||
"""
|
||||
i1 = Individual.objects.create(alive=True)
|
||||
RelatedIndividual.objects.create(related=i1)
|
||||
i2 = Individual.objects.create(alive=False)
|
||||
RelatedIndividual.objects.create(related=i2)
|
||||
i3 = Individual.objects.create(alive=True)
|
||||
i4 = Individual.objects.create(alive=False)
|
||||
|
||||
self.assertQuerysetEqual(
|
||||
Individual.objects.filter(Q(alive=False), Q(related_individual__isnull=True)),
|
||||
[i4], lambda x: x
|
||||
)
|
||||
self.assertQuerysetEqual(
|
||||
Individual.objects.exclude(
|
||||
Q(alive=False), Q(related_individual__isnull=True)
|
||||
).order_by('pk'),
|
||||
[i1, i2, i3], lambda x: x
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user