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

NumberLong compare with Number

    • Major Change
    • ALL
    • Hide
      OnePiece:PRIMARY> db.test.save({_id: 123456789012345680, a: 1})
      WriteResult({
              "nMatched" : 0,
              "nUpserted" : 1,
              "nModified" : 0,
              "_id" : 123456789012345680
      })
      OnePiece:PRIMARY> db.test.save({_id: 408457971232165500, a: 1})
      WriteResult({
              "nMatched" : 0,
              "nUpserted" : 1,
              "nModified" : 0,
              "_id" : 408457971232165500
      })
      OnePiece:PRIMARY> db.test.find()
      { "_id" : 123456789012345680, "a" : 1 }
      { "_id" : 408457971232165500, "a" : 1 }
      OnePiece:PRIMARY> db.test.find({_id: 123456789012345680})
      { "_id" : 123456789012345680, "a" : 1 }
      OnePiece:PRIMARY> db.test.find({_id: NumberLong("123456789012345680")})
      { "_id" : 123456789012345680, "a" : 1 }
      OnePiece:PRIMARY> db.test.find({_id: 408457971232165500})
      { "_id" : 408457971232165500, "a" : 1 }
      OnePiece:PRIMARY> db.test.find({_id: NumberLong("408457971232165500")}) {color:#d04437} (Failed){color}
      OnePiece:PRIMARY>
      
      Show
      OnePiece:PRIMARY> db.test.save({_id: 123456789012345680, a: 1}) WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : 123456789012345680 }) OnePiece:PRIMARY> db.test.save({_id: 408457971232165500, a: 1}) WriteResult({ "nMatched" : 0, "nUpserted" : 1, "nModified" : 0, "_id" : 408457971232165500 }) OnePiece:PRIMARY> db.test.find() { "_id" : 123456789012345680, "a" : 1 } { "_id" : 408457971232165500, "a" : 1 } OnePiece:PRIMARY> db.test.find({_id: 123456789012345680}) { "_id" : 123456789012345680, "a" : 1 } OnePiece:PRIMARY> db.test.find({_id: NumberLong("123456789012345680")}) { "_id" : 123456789012345680, "a" : 1 } OnePiece:PRIMARY> db.test.find({_id: 408457971232165500}) { "_id" : 408457971232165500, "a" : 1 } OnePiece:PRIMARY> db.test.find({_id: NumberLong("408457971232165500")}) {color:#d04437} (Failed){color} OnePiece:PRIMARY>

      When compare number value with NumberLong, unexpect result got.

      PS: The following step get expect result on mongod 2.4, failed both 3.2 && 3.4. (other version not tested)

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            tong20078 tongzhilian
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: