Skip to content

Commit 817b7bc

Browse files
jmfedericovdboor
authored andcommitted
Additional test for FilteredRelation
1 parent 02aaa94 commit 817b7bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

polymorphic/tests/test_orm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,14 @@ def test_polymorphic__filtered_relation(self):
10971097
).aggregate(count=Count("info_joined"))
10981098
self.assertEqual(result, {"count": 2})
10991099

1100+
# We should get a BlogA and a BlogB
1101+
result = BlogBase.objects.annotate(
1102+
info_joined=FilteredRelation("bloga", condition=Q(BlogA___info__contains="joined")),
1103+
).filter(info_joined__isnull=True)
1104+
self.assertEqual(result.count(), 2)
1105+
self.assertIsInstance(result.first(), BlogA)
1106+
self.assertIsInstance(result.last(), BlogB)
1107+
11001108
def test_polymorphic__expressions(self):
11011109

11021110
from django.db.models.functions import Concat

0 commit comments

Comments
 (0)