Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #19187 -- Raise consistent error from qs.values().delete()

  • Loading branch information...
commit 7de439f32d5da88f8a5717717a9e152441708a9f 1 parent 11b8712
@akaariai akaariai authored
View
6 django/db/models/query.py
@@ -983,6 +983,12 @@ def iterator(self):
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
View
6 tests/regressiontests/delete_regress/tests.py
@@ -267,6 +267,12 @@ def test_delete_proxy_pair(self):
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
Please sign in to comment.
Something went wrong with that request. Please try again.