-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
Use Case
As a javascript user
I want javascript numbers to remain doubles when serialized
So that even integer-like doubles do not get converted to int32s
User Impact
- JS numbers that are integers and are within an int32 range are serialized as int32
- This leads to behavior like: c.insertOne({ a: 1.7 + 0.3 }), a becoming an int32 here because the arithmetic resulted in a small integer-like value.
- If BSON were to always use doubles it would increase the default storage usage for numbers.
- MongoDB has flexible number comparison, generally lookups are not impacted by numbers changing type information.
Dependencies
- NODE-4780: promoteValues is the opposite side of the problem here, if enabled the flag will return Double instances, this can be useful for preserving the roundtrip type information
Unknowns
- How would serializing JS numbers to doubles with either a flag or by default impact the driver's messages to the server? (Non-user data, hellos, etc.)
Acceptance Criteria
Implementation Requirements
- Write up a document with investigation findings.
Follow Up Requirements
- Downstream impacts; Does mongosh want to offer or adopt this flag to offer legacy shell behavior. What granularity is necessary?
- is depended on by
-
NODE-4946 Cast Javascript Number as bsonType: "double"
- Blocked
- related to
-
MONGOSH-602 Numeric values are stored as Int32 instead of Double
- Closed
-
NODE-3164 Mongo JS Driver Inserting Ints Instead of Doubles
- Closed
-
NODE-4680 Allow bson to apply transforms on fields during CRUD operations based on field type and/or name
- Backlog