diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-30 07:31:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 07:31:56 +0200 |
commit | fac662f4798f7e4e0ed9be6b4fb4a87a80810a68 (patch) | |
tree | 75583c194e54b896173c489b84c0af499cf95751 /tests/filtered_relation | |
parent | 59ab3fd0e9e606d7f0f7ca26609c06ee679ece97 (diff) | |
download | django-fac662f4798f7e4e0ed9be6b4fb4a87a80810a68.tar.gz |
Fixed #33598 -- Reverted "Removed unnecessary reuse_with_filtered_relation argument from Query methods."
Thanks lind-marcus for the report.
This reverts commit 0c71e0f9cfa714a22297ad31dd5613ee548db379.
Regression in 0c71e0f9cfa714a22297ad31dd5613ee548db379.
Diffstat (limited to 'tests/filtered_relation')
-rw-r--r-- | tests/filtered_relation/tests.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 790a90d9e2..fe7f84bcdb 100644 --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -211,6 +211,34 @@ class FilteredRelationTests(TestCase): str(queryset.query), ) + def test_multiple(self): + qs = ( + Author.objects.annotate( + book_title_alice=FilteredRelation( + "book", condition=Q(book__title__contains="Alice") + ), + book_title_jane=FilteredRelation( + "book", condition=Q(book__title__icontains="Jane") + ), + ) + .filter(name="Jane") + .values("book_title_alice__title", "book_title_jane__title") + ) + empty = "" if connection.features.interprets_empty_strings_as_nulls else None + self.assertCountEqual( + qs, + [ + { + "book_title_alice__title": empty, + "book_title_jane__title": "The book by Jane A", + }, + { + "book_title_alice__title": empty, + "book_title_jane__title": "The book by Jane B", + }, + ], + ) + def test_with_multiple_filter(self): self.assertSequenceEqual( Author.objects.annotate( |