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

Numeric values are stored as Int32 instead of Double

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Won't Fix
    • None
    • No version
    • Shell
    • None
    • 1
    • Needed
    • 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.

    Description

      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 }
      }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: