Manipulate defaults to False in find_and_modify.

This commit is contained in:
Bernie Hackett 2014-11-02 08:06:33 -08:00
parent 5ccd02653a
commit 6a39f811b2
2 changed files with 9 additions and 9 deletions

View File

@ -1623,7 +1623,7 @@ class Collection(common.BaseObject):
def find_and_modify(self, query={}, update=None,
upsert=False, sort=None, full_response=False,
manipulate=True, **kwargs):
manipulate=False, **kwargs):
"""Update and return an object.
This is a thin wrapper around the findAndModify_ command. The
@ -1655,9 +1655,9 @@ class Collection(common.BaseObject):
- `new`: return updated rather than original object
(default ``False``)
- `fields`: see second argument to :meth:`find` (default all)
- `manipulate`: (optional): If True (the default), apply any
outgoing SON manipulators before returning. Do not works when
`full_response` is set to True.
- `manipulate`: (optional): If ``True``, apply any outgoing SON
manipulators before returning. Ignored when `full_response`
is set to True. Defaults to ``False``.
- `**kwargs`: any other options the findAndModify_ command
supports can be passed here.

View File

@ -2375,17 +2375,17 @@ class TestCollection(unittest.TestCase):
# Test correct findAndModify
# With manipulators
self.assertEqual({'_id': 1, 'i': 1, 'collection': 'test'},
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}}))
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}},
manipulate=True))
self.assertEqual({'_id': 1, 'i': 3, 'collection': 'test'},
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}},
new=True))
new=True, manipulate=True))
# With out manipulators
self.assertEqual({'_id': 1, 'i': 3},
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}},
manipulate=False))
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}}))
self.assertEqual({'_id': 1, 'i': 5},
c.find_and_modify({'_id': 1}, {'$inc': {'i': 1}},
new=True, manipulate=False))
new=True))
if __name__ == "__main__":