[SERVER-23936] insertOne method accepts non-documents Created: 26/Apr/16  Updated: 19/Nov/16  Resolved: 13/Sep/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.3.5
Fix Version/s: 3.3.14

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Matt Cotter
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

>  db.foo.drop()
>  db.foo.insertOne(1)
{
	"acknowledged" : true,
	"insertedId" : ObjectId("571fa2fa9e984050a87fc904")
}
> db.foo.findOne()
{
	"_id" : ObjectId("571fa2fa9e984050a87fc904"),
	"toPercentStr" : function () {
    return (this * 100).toFixed(2) + "%";
},
	"zeroPad" : function (width) {
    return ('' + this).pad(width, false, '0');
}
}

Sprint: Platforms 2016-09-19
Participants:

 Description   

The insertOne method accepts non-documents and ends up inserting garbage data. The insert method reports an error in the same situation.

> db.foo.insert(1)
2016-04-26T13:22:39.696-0400 E QUERY    [thread1] Error: attempted to save a number value.  document expected. 



 Comments   
Comment by Githook User [ 13/Sep/16 ]

Author:

{u'username': u'Machyne', u'name': u'Matt Cotter', u'email': u'matt.cotter@mongodb.com'}

Message: SERVER-23936 insertOne only accepts objects
Branch: master
https://github.com/mongodb/mongo/commit/cbbb6730683a8ef3620061a5a3a74da85460f501

Generated at Thu Feb 08 04:04:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.