mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[3.2.x] Refs #32455 -- Added tests for left combining an empty Q() with boolean expressions.
Backport of efce21497cc21140c5fe2b133064cd815c97b3f5 from master
This commit is contained in:
parent
0e2979e95d
commit
732cf4c5b4
@ -804,6 +804,18 @@ class BasicExpressionsTests(TestCase):
|
|||||||
[self.example_inc.ceo, self.max],
|
[self.example_inc.ceo, self.max],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_boolean_expression_combined_with_empty_Q(self):
|
||||||
|
is_poc = Company.objects.filter(point_of_contact=OuterRef('pk'))
|
||||||
|
self.gmbh.point_of_contact = self.max
|
||||||
|
self.gmbh.save()
|
||||||
|
tests = [
|
||||||
|
Exists(is_poc) & Q(),
|
||||||
|
Exists(is_poc) | Q(),
|
||||||
|
]
|
||||||
|
for conditions in tests:
|
||||||
|
with self.subTest(conditions):
|
||||||
|
self.assertCountEqual(Employee.objects.filter(conditions), [self.max])
|
||||||
|
|
||||||
|
|
||||||
class IterableLookupInnerExpressionsTests(TestCase):
|
class IterableLookupInnerExpressionsTests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user