Added support for pull operations on nested EmbeddedDocs

fixes mongoengine/mongoengine#16
This commit is contained in:
Ross Lawley
2012-05-09 14:38:53 +01:00
parent bbefd0fdf9
commit a536097804
3 changed files with 42 additions and 3 deletions

View File

@@ -1380,9 +1380,18 @@ class QuerySet(object):
if not op:
raise InvalidQueryError("Updates must supply an operation eg: set__FIELD=value")
if op:
if 'pull' in op and '.' in key:
# Dot operators don't work on pull operations
# it uses nested dict syntax
if op == 'pullAll':
raise InvalidQueryError("pullAll operations only support a single field depth")
parts.reverse()
for key in parts:
value = {key: value}
else:
value = {key: value}
key = '$' + op
key = '$' + op
if key not in mongo_update:
mongo_update[key] = value