Skip to content

Commit 3392d55

Browse files
committed
Resolve a deprecation warning for insert vs insert_one
1 parent df57c95 commit 3392d55

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ming/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def save(self, doc, *args, **kwargs):
166166
@annotate_doc_failure
167167
def insert(self, doc, **kwargs):
168168
data = self._prep_save(doc, kwargs.pop('validate', True))
169-
bson = self._impl(doc).insert(data, **fix_write_concern(kwargs))
169+
bson = self._impl(doc).insert_one(data, **fix_write_concern(kwargs))
170170
if bson and '_id' not in doc:
171171
doc._id = bson
172172
return bson

ming/tests/test_session.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_base_session(self):
7575
sess.insert(doc)
7676
sess.delete(doc)
7777
impl.save.assert_called_with(doc)
78-
impl.insert.assert_called_with(doc)
78+
impl.insert_one.assert_called_with(doc)
7979
impl.remove.assert_called_with(dict(_id=None))
8080

8181
doc = self.TestDocNoSchema({'_id':5, 'a':5})
@@ -85,9 +85,9 @@ def test_base_session(self):
8585
sess.save(doc, 'a')
8686
impl.update.assert_called_with(dict(_id=5), {'$set':dict(a=5)})
8787
doc = self.TestDocNoSchema({'_id':5, 'a':5})
88-
impl.insert.return_value = bson.ObjectId()
88+
impl.insert_one.return_value = bson.ObjectId()
8989
sess.insert(doc)
90-
impl.insert.assert_called_with(dict(_id=5, a=5))
90+
impl.insert_one.assert_called_with(dict(_id=5, a=5))
9191
doc = self.TestDocNoSchema({'_id':5, 'a':5})
9292
sess.upsert(doc, ['a'])
9393
impl.update.assert_called_with(dict(a=5), dict(_id=5, a=5), upsert=True)

0 commit comments

Comments
 (0)