don't manipulate documents being updated by default
This commit is contained in:
parent
96caf793a3
commit
a4b642b7ab
@ -176,7 +176,7 @@ class Collection(object):
|
||||
|
||||
return len(docs) == 1 and docs[0] or docs
|
||||
|
||||
def update(self, spec, document, upsert=False, manipulate=True, safe=False):
|
||||
def update(self, spec, document, upsert=False, manipulate=False, safe=False):
|
||||
"""Update an object(s) in this collection.
|
||||
|
||||
Raises TypeError if either spec or document isn't an instance of
|
||||
|
||||
@ -273,6 +273,16 @@ class TestCollection(unittest.TestCase):
|
||||
self.assertEqual(db.test.find_one(id1)["x"], 7)
|
||||
self.assertEqual(db.test.find_one(id2)["x"], 1)
|
||||
|
||||
def test_upsert(self):
|
||||
db = self.db
|
||||
db.drop_collection("test")
|
||||
|
||||
db.test.update({"page": "/"}, {"$inc": {"count": 1}}, upsert=True)
|
||||
db.test.update({"page": "/"}, {"$inc": {"count": 1}}, upsert=True)
|
||||
|
||||
self.assertEqual(1, db.test.count())
|
||||
self.assertEqual(2, db.test.find_one()["count"])
|
||||
|
||||
def test_safe_update(self):
|
||||
db = self.db
|
||||
db.drop_collection("test")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user