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

illegal document insert sucess but find fucntion return error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • ALL
    • Hide

      var a = new Timestamp();
      db.test.insert(a);
      var b = new String("123");
      db.test.insert(b);
      res_malie:PRIMARY> db.test.find();

      Show
      var a = new Timestamp(); db.test.insert(a); var b = new String("123"); db.test.insert(b); res_malie:PRIMARY> db.test.find();

      var a = new Timestamp();
      db.test.insert(a);
      mongo shell can run this insert command it doesn't need validate _id?
      
      var b = new String("123");
      db.test.insert(b)
      this can also done
      but if we run find() , it return error
      res_malie:PRIMARY> db.test.find();
      { "_id" : ObjectId("57be5382bd9465a0ef04aaed"), "a" : 5, "b" : 5 }
      { "_id" : ObjectId("57be53b4bd9465a0ef04aaee"), "a" : 2 }
      { "_id" : ObjectId("57be5382bd9465a0ef04aaee") }
      { "_id" : ObjectId("5874e3dea1369cbc0d880fbf"), "timestamp" : Timestamp(1484055375, 0) }
      { "_id" : ObjectId("5874ead321ce10a26f6b7d9b"), "a" : "a" }
      { "_id" : ObjectId("5874ead621ce10a26f6b7d9c"), "a" : "A" }
      Timestamp(0, 0)
      Timestamp(0, 0)
      Timestamp(0, 0)
      Timestamp(0, 0)
      2017-01-11T14:20:31.084+0800 E QUERY    [thread1] SyntaxError: missing ] after element list :
      tojsonObject@src/mongo/shell/types.js:708:13
      tojson@src/mongo/shell/types.js:653:21
      DBQuery.prototype.shellPrint@src/mongo/shell/query.js:533:63
      shellPrintHelper@src/mongo/shell/utils.js:490:1
      @(shell2):1:1
      
      Error: SyntaxError: missing ] after element list :
      tojsonObject@src/mongo/shell/types.js:708:13
      tojson@src/mongo/shell/types.js:653:21
      DBQuery.prototype.shellPrint@src/mongo/shell/query.js:533:63
      shellPrintHelper@src/mongo/shell/utils.js:490:1
      @(shell2):1:1
      
      
      
      I found in mongorestore and other tools have a --objcheck default option
      
      but mongod I find nothing
      so
      it's a mongo shell bug ?
      

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            402309718@qq.com Malie
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: