Skip to content

Commit

Permalink
Resolve a deprecation warning for insert vs insert_one
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Mar 15, 2024
1 parent df57c95 commit 3392d55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ming/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def save(self, doc, *args, **kwargs):
@annotate_doc_failure
def insert(self, doc, **kwargs):
data = self._prep_save(doc, kwargs.pop('validate', True))
bson = self._impl(doc).insert(data, **fix_write_concern(kwargs))
bson = self._impl(doc).insert_one(data, **fix_write_concern(kwargs))
if bson and '_id' not in doc:
doc._id = bson
return bson
Expand Down
6 changes: 3 additions & 3 deletions ming/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_base_session(self):
sess.insert(doc)
sess.delete(doc)
impl.save.assert_called_with(doc)
impl.insert.assert_called_with(doc)
impl.insert_one.assert_called_with(doc)
impl.remove.assert_called_with(dict(_id=None))

doc = self.TestDocNoSchema({'_id':5, 'a':5})
Expand All @@ -85,9 +85,9 @@ def test_base_session(self):
sess.save(doc, 'a')
impl.update.assert_called_with(dict(_id=5), {'$set':dict(a=5)})
doc = self.TestDocNoSchema({'_id':5, 'a':5})
impl.insert.return_value = bson.ObjectId()
impl.insert_one.return_value = bson.ObjectId()
sess.insert(doc)
impl.insert.assert_called_with(dict(_id=5, a=5))
impl.insert_one.assert_called_with(dict(_id=5, a=5))
doc = self.TestDocNoSchema({'_id':5, 'a':5})
sess.upsert(doc, ['a'])
impl.update.assert_called_with(dict(a=5), dict(_id=5, a=5), upsert=True)
Expand Down

0 comments on commit 3392d55

Please sign in to comment.