summaryrefslogtreecommitdiff
path: root/tests/filtered_relation
diff options
context:
space:
mode:
authorcan <cansarigol@derinbilgi.com.tr>2019-04-23 13:56:05 +0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-23 13:48:33 +0200
commitc00b4dbda2d9217cac205c4ffb3ccc1fa59a28ae (patch)
tree4adc842e5e28553247453900fb82aba17b2661f0 /tests/filtered_relation
parent6fd9c9daa61b7103ccb03a7618483e4d580bfe25 (diff)
downloaddjango-c00b4dbda2d9217cac205c4ffb3ccc1fa59a28ae.tar.gz
Fixed #29810 -- Fixed crash of select_related() on FilteredRelation with empty result.
Diffstat (limited to 'tests/filtered_relation')
-rw-r--r--tests/filtered_relation/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
index 2596dcbdc2..5e85dff16c 100644
--- a/tests/filtered_relation/tests.py
+++ b/tests/filtered_relation/tests.py
@@ -50,6 +50,12 @@ 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_with_empty_relation(self):
+ qs = Author.objects.annotate(
+ book_join=FilteredRelation('book', condition=Q(pk=-1)),
+ ).select_related('book_join').order_by('pk')
+ self.assertSequenceEqual(qs, [self.author1, self.author2])
+
def test_select_related_foreign_key(self):
qs = Book.objects.annotate(
author_join=FilteredRelation('author'),