Fixed #31148 -- Added error messages on update()/delete() operations following union(), intersection(), and difference().
This commit is contained in:
parent
f600e3fad6
commit
eef3ea847e
|
@ -711,6 +711,7 @@ class QuerySet:
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""Delete the records in the current QuerySet."""
|
"""Delete the records in the current QuerySet."""
|
||||||
|
self._not_support_combined_queries('delete')
|
||||||
assert not self.query.is_sliced, \
|
assert not self.query.is_sliced, \
|
||||||
"Cannot use 'limit' or 'offset' with delete."
|
"Cannot use 'limit' or 'offset' with delete."
|
||||||
|
|
||||||
|
@ -756,6 +757,7 @@ class QuerySet:
|
||||||
Update all elements in the current QuerySet, setting all the given
|
Update all elements in the current QuerySet, setting all the given
|
||||||
fields to the appropriate values.
|
fields to the appropriate values.
|
||||||
"""
|
"""
|
||||||
|
self._not_support_combined_queries('update')
|
||||||
assert not self.query.is_sliced, \
|
assert not self.query.is_sliced, \
|
||||||
"Cannot update a query once a slice has been taken."
|
"Cannot update a query once a slice has been taken."
|
||||||
self._for_write = True
|
self._for_write = True
|
||||||
|
|
|
@ -272,12 +272,14 @@ class QuerySetSetOperationTests(TestCase):
|
||||||
for operation in (
|
for operation in (
|
||||||
'annotate',
|
'annotate',
|
||||||
'defer',
|
'defer',
|
||||||
|
'delete',
|
||||||
'exclude',
|
'exclude',
|
||||||
'extra',
|
'extra',
|
||||||
'filter',
|
'filter',
|
||||||
'only',
|
'only',
|
||||||
'prefetch_related',
|
'prefetch_related',
|
||||||
'select_related',
|
'select_related',
|
||||||
|
'update',
|
||||||
):
|
):
|
||||||
with self.subTest(combinator=combinator, operation=operation):
|
with self.subTest(combinator=combinator, operation=operation):
|
||||||
with self.assertRaisesMessage(
|
with self.assertRaisesMessage(
|
||||||
|
|
Loading…
Reference in New Issue