mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
[1.11.x] Fixed #28199 -- Fixed Subquery generating unnecessary/invalid CAST.
Thanks Simon Charette for the fix.
Backport of f04495521a from master
This commit is contained in:
@@ -25,7 +25,8 @@ from django.test.utils import Approximate
|
||||
from django.utils import six
|
||||
|
||||
from .models import (
|
||||
UUID, Company, Employee, Experiment, Number, Result, SimulationRun, Time,
|
||||
UUID, UUIDPK, Company, Employee, Experiment, Number, Result, SimulationRun,
|
||||
Time,
|
||||
)
|
||||
|
||||
|
||||
@@ -480,6 +481,12 @@ class BasicExpressionsTests(TestCase):
|
||||
subquery_test2 = Company.objects.filter(pk=Subquery(small_companies.filter(num_employees=3)))
|
||||
self.assertCountEqual(subquery_test2, [self.foobar_ltd])
|
||||
|
||||
def test_uuid_pk_subquery(self):
|
||||
u = UUIDPK.objects.create()
|
||||
UUID.objects.create(uuid_fk=u)
|
||||
qs = UUIDPK.objects.filter(id__in=Subquery(UUID.objects.values('uuid_fk__id')))
|
||||
self.assertCountEqual(qs, [u])
|
||||
|
||||
def test_nested_subquery(self):
|
||||
inner = Company.objects.filter(point_of_contact=OuterRef('pk'))
|
||||
outer = Employee.objects.annotate(is_point_of_contact=Exists(inner))
|
||||
|
||||
Reference in New Issue
Block a user