Updates must have an operation

Closes #387
This commit is contained in:
Ross Lawley
2012-02-29 11:04:09 +00:00
parent 2afa2171f9
commit 44b9fb66e1
3 changed files with 11 additions and 1 deletions

View File

@@ -1332,11 +1332,14 @@ class QuerySet(object):
key = '.'.join(parts)
if not op:
raise InvalidQueryError("Updates must supply an operation eg: set__FIELD=value")
if op:
value = {key: value}
key = '$' + op
if op is None or key not in mongo_update:
if key not in mongo_update:
mongo_update[key] = value
elif key in mongo_update and isinstance(mongo_update[key], dict):
mongo_update[key].update(value)