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

Attempt to update Double to NumberInt is ignored

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.8, 3.2.0
    • Component/s: None
    • Labels:
      None
    • ALL

      Attempts to $set a Double to NumberInt seem to be ignored when the values are numerically equal.

      threetwo:PRIMARY> db.version()
      3.2.0
      
      // Insert a document where x is a Double
      threetwo:PRIMARY> db.foo.insert({x: 1})
      WriteResult({ "nInserted" : 1 })
      
      // Verify it's a Double
      threetwo:PRIMARY> db.foo.find({x: {$type:1}})
      { "_id" : ObjectId("56829f8f891b45519f22028c"), "x" : 1 }
      
      // Update to NumberInt
      threetwo:PRIMARY> db.foo.update({ "_id" : ObjectId("56829f8f891b45519f22028c")},{$set: {x: NumberInt(1)}})
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
      
      // Note nModified of 0, and field is still Double
      threetwo:PRIMARY> db.foo.find({x: {$type:1}})
      { "_id" : ObjectId("56829f8f891b45519f22028c"), "x" : 1 }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            cailin.nelson@mongodb.com Cailin Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: