1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

[5.0.x] Fixed #35135 -- Made FilteredRelation raise ValueError on querysets as rhs.

Regression in 59f4754704.

Backport of 820c5f1bac from main
This commit is contained in:
Nicolas Delaby
2024-01-23 11:51:24 +01:00
committed by Mariusz Felisiak
parent 28d6db26a2
commit a5440054d2
3 changed files with 25 additions and 0 deletions

View File

@@ -828,6 +828,16 @@ class FilteredRelationTests(TestCase):
).filter(rel__isnull=True)
self.assertSequenceEqual(qs, [])
def test_conditional_expression_does_not_support_queryset(self):
msg = "Passing a QuerySet within a FilteredRelation is not supported."
with self.assertRaisesMessage(ValueError, msg):
Author.objects.annotate(
poem_book=FilteredRelation(
"book",
condition=Q(book__in=Book.objects.filter(title__istartswith="a")),
),
).filter(poem_book__isnull=False)
class FilteredRelationAggregationTests(TestCase):
@classmethod