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

Attempt to update Double to NumberInt is ignored

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 3.0.8, 3.2.0
    • None
    • None
    • None
    • ALL

    Description

      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 }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: