mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user