summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-10-10 21:13:21 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-11 09:18:23 +0200
commitc1cfec6b500c16200a4c2ef5676439c3cc987bc2 (patch)
tree2a523b021b2c6a8c03c63cddffe318abe95f4083 /tests
parent0dede9e9814282d6813270cd4cdd65166d119522 (diff)
[3.0.x] Fixed #30854 -- Fixed QuerySet.select_related() with multiple FilteredRelations.
Backport of 6a75cea76a98c08bf2e20d787be9b14c2cd94860 from master.
Diffstat (limited to 'tests')
-rw-r--r--tests/filtered_relation/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
index 52fe64dfa5..e80a94c164 100644
--- a/tests/filtered_relation/tests.py
+++ b/tests/filtered_relation/tests.py
@@ -50,6 +50,18 @@ class FilteredRelationTests(TestCase):
(self.author2, self.book3, self.editor_b, self.author2),
], lambda x: (x, x.book_join, x.book_join.editor, x.book_join.author))
+ def test_select_related_multiple(self):
+ qs = Book.objects.annotate(
+ author_join=FilteredRelation('author'),
+ editor_join=FilteredRelation('editor'),
+ ).select_related('author_join', 'editor_join').order_by('pk')
+ self.assertQuerysetEqual(qs, [
+ (self.book1, self.author1, self.editor_a),
+ (self.book2, self.author2, self.editor_b),
+ (self.book3, self.author2, self.editor_b),
+ (self.book4, self.author1, self.editor_a),
+ ], lambda x: (x, x.author_join, x.editor_join))
+
def test_select_related_with_empty_relation(self):
qs = Author.objects.annotate(
book_join=FilteredRelation('book', condition=Q(pk=-1)),