Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-602

Numeric values are stored as Int32 instead of Double

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: Embedded Shell
    • None
    • 1
    • Needed
    • Hide

      Unlike mongo where numbers are always stored as doubles unless differently specified, mongosh will have the javascript behavior: 1 is an int32, 1.1 is a double.

      Show
      Unlike mongo where numbers are always stored as doubles unless differently specified, mongosh will have the javascript behavior: 1 is an int32, 1.1 is a double.

      mongosh should insert number as Double by default.

      Currently number in mongosh are inserted as int32 if they can be represented as integer and as double otherwise.

      ie.

      db.coll1.insertOne({
        x: 1
      });
      

      will result in a bson document like this:

      {
          _id: 602aa63a5eabf03429d733f1,
          x: Int32 { _bsontype: 'Int32', value: 1 }
      }
      

      where the old shell would have inserted a Double:

      {
          _id: 602aa5da098e6ce990139172,
          x: Double { _bsontype: 'Double', value: 1 }
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: