mirror of https://github.com/django/django.git
Fixed #19187 -- Raise consistent error from qs.values().delete()
This commit is contained in:
parent
11b8712cc7
commit
7de439f32d
|
@ -983,6 +983,12 @@ class ValuesQuerySet(QuerySet):
|
|||
for row in self.query.get_compiler(self.db).results_iter():
|
||||
yield dict(zip(names, row))
|
||||
|
||||
def delete(self):
|
||||
# values().delete() doesn't work currently - make sure it raises an
|
||||
# user friendly error.
|
||||
raise TypeError("Queries with .values() or .values_list() applied "
|
||||
"can't be deleted")
|
||||
|
||||
def _setup_query(self):
|
||||
"""
|
||||
Constructs the field_names list that the values query will be
|
||||
|
|
|
@ -267,6 +267,12 @@ class ProxyDeleteTest(TestCase):
|
|||
|
||||
self.assertEqual(len(FooFileProxy.objects.all()), 0)
|
||||
|
||||
def test_19187_values(self):
|
||||
with self.assertRaises(TypeError):
|
||||
Image.objects.values().delete()
|
||||
with self.assertRaises(TypeError):
|
||||
Image.objects.values_list().delete()
|
||||
|
||||
class Ticket19102Tests(TestCase):
|
||||
"""
|
||||
Test different queries which alter the SELECT clause of the query. We
|
||||
|
|
Loading…
Reference in New Issue