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

NumberDecimal accepts any random string

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.8
    • Affects Version/s: 3.3.4
    • Component/s: Shell
    • None
    • Fully Compatible
    • ALL
    • Integrate+Tuning 15 (06/03/16)

      It seems like you can pass any string random string that doesn't match an IEEE 754 decimal to NumberDecimal and the shell will happily encode it as "NaN". Should it error if the value makes no sense?

      MongoDB Enterprise repl0:PRIMARY> db.test.count()
      0
      MongoDB Enterprise repl0:PRIMARY> db.test.insert({d: NumberDecimal("this is total garbage")})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise repl0:PRIMARY> db.test.count()
      1
      MongoDB Enterprise repl0:PRIMARY> db.test.findOne()
      { "_id" : ObjectId("570ed43b02e7d49d28d860aa"), "d" : NumberDecimal("NaN") }
      

            Assignee:
            vincent.do@mongodb.com Vincent Do
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: