summaryrefslogtreecommitdiff
path: root/tests/expressions
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-18 21:32:38 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-18 22:19:56 +0100
commitefce21497cc21140c5fe2b133064cd815c97b3f5 (patch)
tree5391869314c693a3f8729ccc6a5f259bea2aa72e /tests/expressions
parent466920f6d726eee90d5566e0a9948e92b33a122e (diff)
downloaddjango-efce21497cc21140c5fe2b133064cd815c97b3f5.tar.gz
Refs #32455 -- Added tests for left combining an empty Q() with boolean expressions.
Diffstat (limited to 'tests/expressions')
-rw-r--r--tests/expressions/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index 08ea0a51d3..770a57d66e 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -816,6 +816,18 @@ class BasicExpressionsTests(TestCase):
[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):
@classmethod