diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-06-09 16:17:54 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-06-09 16:17:54 +0000 |
| commit | b5f92938abd64f5577eea9f80925d71bc7968c09 (patch) | |
| tree | a36e648fcf2dc2dacb6e7ae6b3e63586750e3edb /django | |
| parent | 12716794dbcf2e1bf7a07bd18dfc0ae24be4e6f8 (diff) | |
Fixed #7298: prevent update() on sliced QuerySet since UPDATE doesn't reliably support LIMIT/OFFSET. Thanks, George Vilches.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7601 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 6b341ba9ab..12731caa94 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -292,6 +292,8 @@ class QuerySet(object): Updates all elements in the current QuerySet, setting all the given fields to the appropriate values. """ + assert self.query.can_filter(), \ + "Cannot update a query once a slice has been taken." query = self.query.clone(sql.UpdateQuery) query.add_update_values(kwargs) query.execute_sql(None) @@ -306,6 +308,8 @@ class QuerySet(object): code (it requires too much poking around at model internals to be useful at that level). """ + assert self.query.can_filter(), \ + "Cannot update a query once a slice has been taken." query = self.query.clone(sql.UpdateQuery) query.add_update_fields(values) query.execute_sql(None) |
