mirror of
https://github.com/django/django.git
synced 2025-10-02 23:04:53 +00:00
Added the ability to force an SQL insert (or force an update) via a model's
save() method. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f53e4d80b4
commit
dc14b29fb3
6 changed files with 115 additions and 12 deletions
|
@ -399,9 +399,10 @@ class QuerySet(object):
|
|||
"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)
|
||||
rows = query.execute_sql(None)
|
||||
transaction.commit_unless_managed()
|
||||
self._result_cache = None
|
||||
return rows
|
||||
update.alters_data = True
|
||||
|
||||
def _update(self, values):
|
||||
|
@ -415,8 +416,8 @@ class QuerySet(object):
|
|||
"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)
|
||||
self._result_cache = None
|
||||
return query.execute_sql(None)
|
||||
_update.alters_data = True
|
||||
|
||||
##################################################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue