mirror of https://github.com/django/django.git
Fixed #29142 -- Fixed crash when OuterRef is used with an operator.
This commit is contained in:
parent
f5c6fc045a
commit
c412926a2e
|
@ -525,6 +525,9 @@ class ResolvedOuterRef(F):
|
||||||
def _prepare(self, output_field=None):
|
def _prepare(self, output_field=None):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def relabeled_clone(self, relabels):
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class OuterRef(F):
|
class OuterRef(F):
|
||||||
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
|
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
|
||||||
|
|
|
@ -575,6 +575,11 @@ class BasicExpressionsTests(TestCase):
|
||||||
outer = Result.objects.filter(pk__in=Subquery(inner.values('pk')))
|
outer = Result.objects.filter(pk__in=Subquery(inner.values('pk')))
|
||||||
self.assertFalse(outer.exists())
|
self.assertFalse(outer.exists())
|
||||||
|
|
||||||
|
def test_outerref_with_operator(self):
|
||||||
|
inner = Company.objects.filter(num_employees=OuterRef('ceo__salary') + 2)
|
||||||
|
outer = Company.objects.filter(pk__in=Subquery(inner.values('pk')))
|
||||||
|
self.assertEqual(outer.get().name, 'Test GmbH')
|
||||||
|
|
||||||
|
|
||||||
class IterableLookupInnerExpressionsTests(TestCase):
|
class IterableLookupInnerExpressionsTests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue