1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #29142 -- Fixed crash when OuterRef is used with an operator.

This commit is contained in:
Matthew Schinckel 2018-02-23 18:01:01 +10:30 committed by Tim Graham
parent f5c6fc045a
commit c412926a2e
2 changed files with 8 additions and 0 deletions

View File

@ -525,6 +525,9 @@ class ResolvedOuterRef(F):
def _prepare(self, output_field=None):
return self
def relabeled_clone(self, relabels):
return self
class OuterRef(F):
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):

View File

@ -575,6 +575,11 @@ class BasicExpressionsTests(TestCase):
outer = Result.objects.filter(pk__in=Subquery(inner.values('pk')))
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):
@classmethod