Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-23936

insertOne method accepts non-documents

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.3.5
    • Fix Version/s: 3.3.14
    • Component/s: Shell
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      >  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');
      }
      }
      

      Show
      > 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

      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. 
      

        Attachments

          Activity

            People

            Assignee:
            matt.cotter Matt Cotter
            Reporter:
            jeff.yemin Jeffrey Yemin
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: