mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[soc2010/query-refactor] Fixed update on MongoDB.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13342 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7ce89032b6
commit
28499bbe36
@ -75,4 +75,13 @@ class SQLInsertCompiler(SQLCompiler):
|
|||||||
return self.connection.db[self.query.model._meta.db_table].insert(values)
|
return self.connection.db[self.query.model._meta.db_table].insert(values)
|
||||||
|
|
||||||
class SQLUpdateCompiler(SQLCompiler):
|
class SQLUpdateCompiler(SQLCompiler):
|
||||||
pass
|
def update(self, result_type):
|
||||||
|
# TODO: more asserts
|
||||||
|
filters = self.get_filters(self.query.where)
|
||||||
|
# TODO: Don't use set for everything, use INC and such where
|
||||||
|
# appropriate.
|
||||||
|
return self.connection.db[self.query.model._meta.db_table].update(
|
||||||
|
filters,
|
||||||
|
{"$set": dict((f.column, val) for f, o, val in self.query.values)},
|
||||||
|
multi=True
|
||||||
|
)
|
||||||
|
@ -488,7 +488,7 @@ class QuerySet(object):
|
|||||||
query = self.query.clone(sql.UpdateQuery)
|
query = self.query.clone(sql.UpdateQuery)
|
||||||
query.add_update_fields(values)
|
query.add_update_fields(values)
|
||||||
self._result_cache = None
|
self._result_cache = None
|
||||||
return query.get_compiler(self.db).execute_sql(None)
|
return query.get_compiler(self.db).update(None)
|
||||||
_update.alters_data = True
|
_update.alters_data = True
|
||||||
|
|
||||||
def exists(self):
|
def exists(self):
|
||||||
|
@ -866,6 +866,9 @@ class SQLUpdateCompiler(SQLCompiler):
|
|||||||
if where:
|
if where:
|
||||||
result.append('WHERE %s' % where)
|
result.append('WHERE %s' % where)
|
||||||
return ' '.join(result), tuple(update_params + params)
|
return ' '.join(result), tuple(update_params + params)
|
||||||
|
|
||||||
|
def update(self, *args, **kwargs):
|
||||||
|
return self.execute_sql(*args, **kwargs)
|
||||||
|
|
||||||
def execute_sql(self, result_type):
|
def execute_sql(self, result_type):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user