1
0
mirror of https://github.com/django/django.git synced 2025-07-05 18:29:11 +00:00

queryset-refactor: Fixed the case of calling update() on a model manager.

git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7146 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-02-23 00:23:57 +00:00
parent e2b3c50cf0
commit e2f524ca09
3 changed files with 10 additions and 2 deletions

View File

@ -102,7 +102,7 @@ class Manager(object):
return self.get_query_set().values(*args, **kwargs)
def update(self, *args, **kwargs):
return self.get_query_set().updated(*args, **kwargs)
return self.get_query_set().update(*args, **kwargs)
def _insert(self, *args, **kwargs):
return self.get_query_set()._insert(*args, **kwargs)

View File

@ -1240,7 +1240,8 @@ class UpdateQuery(Query):
values.append('%s = NULL' % qn(name))
result.append(', '.join(values))
where, params = self.where.as_sql()
result.append('WHERE %s' % where)
if where:
result.append('WHERE %s' % where)
return ' '.join(result), tuple(update_params + params)
def clear_related(self, related_field, pk_list):

View File

@ -56,5 +56,12 @@ Multiple fields can be updated at once
>>> d.value, d.another_value
(u'fruit', u'peaches')
In the rare case you want to update every instance of a model, update() is also
a manager method.
>>> DataPoint.objects.update(value='thing')
>>> DataPoint.objects.values('value').distinct()
[{'value': u'thing'}]
"""
}