Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #12142 -- EmptyQuerySet.update() no longer updates all rows in …

…the database

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12171 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cf1b6845d4cc1c34cfa975f6ba98b7fb966cb491 1 parent 0683a79
@adrianholovaty adrianholovaty authored
Showing with 8 additions and 0 deletions.
  1. +6 −0 django/db/models/query.py
  2. +2 −0  tests/modeltests/lookup/models.py
View
6 django/db/models/query.py
@@ -1089,6 +1089,12 @@ def only(self, *fields):
"""
return self
+ def update(self, **kwargs):
+ """
+ Don't update anything.
+ """
+ return 0
+
# EmptyQuerySet is always an empty result in where-clauses (and similar
# situations).
value_annotation = False
View
2  tests/modeltests/lookup/models.py
@@ -295,6 +295,8 @@ def __unicode__(self):
[]
>>> Article.objects.none().count()
0
+>>> Article.objects.none().update(headline="This should not take effect")
+0
>>> [article for article in Article.objects.none().iterator()]
[]
Please sign in to comment.
Something went wrong with that request. Please try again.