You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
#grid Document View changes numeric BSON types on save (Long and Double become Int32) #rdg #1145
Document View can change numeric BSON types when a document is saved, and it can display a wrong value for a 64-bit integer above 2^53. Found while reviewing #1142; it predates that PR and is outside its scope.
Cause
Document View reads the document with relaxed Extended JSON: EJSON.stringify(...) in getDocumentById (src/webviews/documentdb/documentView/documentsViewRouter.ts:67).
It saves with relaxed parsing: EJSON.parse(input.documentContent) in saveDocument (documentsViewRouter.ts:81).
The driver's default promoteLongs / promoteValues are in effect; no read options are set.
Relaxed Extended JSON writes numbers as plain JSON numbers, so the editor text no longer carries the BSON type, and relaxed parsing picks a type from the number's value.
Evidence
An offline simulation of that read → edit → save path with the installed bson 7.2.0 (driver mongodb 7.2.0) gave:
Field
Stored
Shown in the editor
Saved as
small
Long 5
5
Int32 5
big
Long 9007199254740993
9007199254740992
Double 9007199254740992
dbl
Double 1
1
Int32 1
i32
Int32 7
7
Int32 7 (unchanged)
Not reproduced against a live server; the server stores whatever the driver sends.
Impact
Saving a document without touching a numeric field can still change that field's BSON type (Long → Int32, integral Double → Int32).
A Long above 2^53 is displayed with a wrong value and saved as a rounded Double.
Options
Read with promoteValues: false and keep explicit type wrappers only where relaxed output would lose information (Long, integral Double), so ordinary numbers stay readable. More code, but exact and readable.
Use canonical Extended JSON in both directions. Exact, and a small change, but every number shows as {"$numberInt": "7"} in the editor.
changed the title [-]Document View changes numeric BSON types on save (Long and Double become Int32)[/-][+]#grid Document View changes numeric BSON types on save (Long and Double become Int32)[/+]on Dec 1, 2026
The separate implementation PR is #1148 (target: main); merging #1142 is not evidence that Document View numeric round-tripping is fixed. Keep acceptance for an untouched small Long, a Long above 2^53, and an integral Double, checking both the value and stored BSON type after save. The falsy _id fix in the migration and insert-only Add in #1153 have different causes. These distinctions also matter before any inline editing under #62.
changed the title [-]#grid Document View changes numeric BSON types on save (Long and Double become Int32)[/-][+]#grid Document View changes numeric BSON types on save (Long and Double become Int32) #rdg[/+]on Dec 1, 2026
Activity
[-]Document View changes numeric BSON types on save (Long and Double become Int32)[/-][+]#grid Document View changes numeric BSON types on save (Long and Double become Int32)[/+]tnaum-ms commentedon Dec 1, 2026
The separate implementation PR is #1148 (target:
main); merging #1142 is not evidence that Document View numeric round-tripping is fixed. Keep acceptance for an untouched small Long, a Long above 2^53, and an integral Double, checking both the value and stored BSON type after save. The falsy_idfix in the migration and insert-only Add in #1153 have different causes. These distinctions also matter before any inline editing under #62.[-]#grid Document View changes numeric BSON types on save (Long and Double become Int32)[/-][+]#grid Document View changes numeric BSON types on save (Long and Double become Int32) #rdg[/+]