1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #32068 -- Added error messages on get() with filters following union(), intersection(), and difference().

This commit is contained in:
Hasan Ramezani
2020-10-05 11:51:35 +02:00
committed by Mariusz Felisiak
parent 7cfa40d872
commit 981a3426cf
2 changed files with 18 additions and 0 deletions

View File

@@ -341,3 +341,16 @@ class QuerySetSetOperationTests(TestCase):
msg % (operation, combinator),
):
getattr(getattr(qs, combinator)(qs), operation)()
def test_get_with_filters_unsupported_on_combined_qs(self):
qs = Number.objects.all()
msg = 'Calling QuerySet.get(...) with filters after %s() is not supported.'
combinators = ['union']
if connection.features.supports_select_difference:
combinators.append('difference')
if connection.features.supports_select_intersection:
combinators.append('intersection')
for combinator in combinators:
with self.subTest(combinator=combinator):
with self.assertRaisesMessage(NotSupportedError, msg % combinator):
getattr(qs, combinator)(qs).get(num=2)