mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
[1.6.x] Fixed #22429 -- Incorrect SQL when using ~Q and F
Backpatch of 5e1f4656b9 from master.
Conflicts:
django/db/models/sql/query.py
tests/queries/models.py
tests/queries/tests.py
This commit is contained in:
@@ -27,7 +27,8 @@ from .models import (
|
||||
ModelA, ModelB, ModelC, ModelD, Responsibility, Job, JobResponsibilities,
|
||||
BaseA, FK1, Identifier, Program, Channel, Page, Paragraph, Chapter, Book,
|
||||
MyObject, Order, OrderItem, Task, Staff, StaffUser, Ticket21203Parent,
|
||||
Ticket21203Child)
|
||||
Ticket21203Child, Classroom, School, Student)
|
||||
|
||||
|
||||
class BaseQuerysetTest(TestCase):
|
||||
def assertValueQuerysetEqual(self, qs, values):
|
||||
@@ -3105,3 +3106,18 @@ class ForeignKeyToBaseExcludeTests(TestCase):
|
||||
SpecialCategory.objects.filter(categoryitem__id=c1.pk),
|
||||
[sc1], lambda x: x
|
||||
)
|
||||
|
||||
|
||||
class Ticket22429Tests(TestCase):
|
||||
def test_ticket_22429(self):
|
||||
sc1 = School.objects.create()
|
||||
st1 = Student.objects.create(school=sc1)
|
||||
|
||||
sc2 = School.objects.create()
|
||||
st2 = Student.objects.create(school=sc2)
|
||||
|
||||
cr = Classroom.objects.create(school=sc1)
|
||||
cr.students.add(st1)
|
||||
|
||||
queryset = Student.objects.filter(~Q(classroom__school=F('school')))
|
||||
self.assertQuerysetEqual(queryset, [st2], lambda x: x)
|
||||
|
||||
Reference in New Issue
Block a user