Fixed #31251 -- Disabled grouping by OuterRef() annotation.
This commit is contained in:
parent
5bf28ac2ed
commit
486786c4c4
|
@ -562,6 +562,9 @@ class ResolvedOuterRef(F):
|
|||
def relabeled_clone(self, relabels):
|
||||
return self
|
||||
|
||||
def get_group_by_cols(self, alias=None):
|
||||
return []
|
||||
|
||||
|
||||
class OuterRef(F):
|
||||
def resolve_expression(self, *args, **kwargs):
|
||||
|
|
|
@ -687,6 +687,14 @@ class BasicExpressionsTests(TestCase):
|
|||
[self.foobar_ltd.ceo],
|
||||
)
|
||||
|
||||
def test_subquery_group_by_outerref_in_filter(self):
|
||||
inner = Company.objects.annotate(
|
||||
employee=OuterRef('pk'),
|
||||
).values('employee').annotate(
|
||||
min_num_chairs=Min('num_chairs'),
|
||||
).values('ceo')
|
||||
self.assertIs(Employee.objects.filter(pk__in=Subquery(inner)).exists(), True)
|
||||
|
||||
def test_case_in_filter_if_boolean_output_field(self):
|
||||
is_ceo = Company.objects.filter(ceo=OuterRef('pk'))
|
||||
is_poc = Company.objects.filter(point_of_contact=OuterRef('pk'))
|
||||
|
|
Loading…
Reference in New Issue