mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33127 -- Added error messages on | and & operators with combined querysets.
This commit is contained in:
committed by
Mariusz Felisiak
parent
25cbd1e6aa
commit
f997c81472
@@ -441,3 +441,24 @@ class QuerySetSetOperationTests(TestCase):
|
||||
with self.subTest(combinator=combinator):
|
||||
with self.assertRaisesMessage(NotSupportedError, msg % combinator):
|
||||
getattr(qs, combinator)(qs).get(num=2)
|
||||
|
||||
def test_operator_on_combined_qs_error(self):
|
||||
qs = Number.objects.all()
|
||||
msg = 'Cannot use %s operator with combined queryset.'
|
||||
combinators = ['union']
|
||||
if connection.features.supports_select_difference:
|
||||
combinators.append('difference')
|
||||
if connection.features.supports_select_intersection:
|
||||
combinators.append('intersection')
|
||||
operators = [
|
||||
('|', operator.or_),
|
||||
('&', operator.and_),
|
||||
]
|
||||
for combinator in combinators:
|
||||
combined_qs = getattr(qs, combinator)(qs)
|
||||
for operator_, operator_func in operators:
|
||||
with self.subTest(combinator=combinator):
|
||||
with self.assertRaisesMessage(TypeError, msg % operator_):
|
||||
operator_func(qs, combined_qs)
|
||||
with self.assertRaisesMessage(TypeError, msg % operator_):
|
||||
operator_func(combined_qs, qs)
|
||||
|
||||
Reference in New Issue
Block a user