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
This commit is contained in:
Adrian Holovaty 2010-01-10 17:53:19 +00:00
parent 0683a79d0c
commit cf1b6845d4
2 changed files with 8 additions and 0 deletions

View File

@ -1089,6 +1089,12 @@ class EmptyQuerySet(QuerySet):
"""
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 File

@ -295,6 +295,8 @@ DoesNotExist: Article matching query does not exist.
[]
>>> Article.objects.none().count()
0
>>> Article.objects.none().update(headline="This should not take effect")
0
>>> [article for article in Article.objects.none().iterator()]
[]