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:
Malcolm Tredinnick 2008-08-09 17:19:23 +00:00
parent f53e4d80b4
commit dc14b29fb3
6 changed files with 115 additions and 12 deletions

View file

@ -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
##################################################