diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2010-01-10 17:53:19 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2010-01-10 17:53:19 +0000 |
| commit | cf1b6845d4cc1c34cfa975f6ba98b7fb966cb491 (patch) | |
| tree | 4eb5b119cec9f7adc485bccafc78981545e9fa33 | |
| parent | 0683a79d0c5582d9c7f4aa424713adbfba37bfac (diff) | |
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
| -rw-r--r-- | django/db/models/query.py | 6 | ||||
| -rw-r--r-- | tests/modeltests/lookup/models.py | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 4e3326a9ca..365df96fb0 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -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 diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 512ffd7e7d..72b547a376 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -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()] [] |
