diff options
author | Matt Cotter <matt.cotter@mongodb.com> | 2016-09-06 12:57:16 -0400 |
---|---|---|
committer | Matt Cotter <matt.cotter@mongodb.com> | 2016-09-13 11:22:36 -0400 |
commit | cbbb6730683a8ef3620061a5a3a74da85460f501 (patch) | |
tree | 9c86c2f1fd086c3dba31a7101764a23c55553585 /src/mongo/shell/crud_api.js | |
parent | fec08a992e29f9b0a9a227602b040987d17a940e (diff) | |
download | mongo-cbbb6730683a8ef3620061a5a3a74da85460f501.tar.gz |
SERVER-23936 insertOne only accepts objects
Diffstat (limited to 'src/mongo/shell/crud_api.js')
-rw-r--r-- | src/mongo/shell/crud_api.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mongo/shell/crud_api.js b/src/mongo/shell/crud_api.js index dafbb10510d..e9678cad16a 100644 --- a/src/mongo/shell/crud_api.js +++ b/src/mongo/shell/crud_api.js @@ -27,12 +27,17 @@ DBCollection.prototype._createWriteConcern = function(options) { * Otherwise, returns the same object passed. */ DBCollection.prototype.addIdIfNeeded = function(obj) { + if (typeof obj !== "object") { + throw new Error('argument passed to addIdIfNeeded is not an object'); + } if (typeof(obj._id) == "undefined" && !Array.isArray(obj)) { var tmp = obj; // don't want to modify input obj = {_id: new ObjectId()}; for (var key in tmp) { - obj[key] = tmp[key]; + if (tmp.hasOwnProperty(key)) { + obj[key] = tmp[key]; + } } } |