-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Shell API
-
None
-
Environment:buildInfo()
{
version: '2.5.0',
distributionKind: 'compiled',
buildArch: 'x64',
buildPlatform: 'linux',
buildTarget: 'linux-x64-openssl3',
buildTime: '2025-04-08T13:07:57.160Z',
gitVersion: '2b03591a8cde3171c86f11d4217352266f1b1a9c',
nodeVersion: 'v20.19.0',
opensslVersion: '3.2.4',
sharedOpenssl: true,
runtimeArch: 'x64',
runtimePlatform: 'linux',
runtimeGlibcVersion: '2.40',
deps: {
nodeDriverVersion: '6.14.2',
libmongocryptVersion: '1.13.0',
libmongocryptNodeBindingsVersion: '6.3.0',
kerberosVersion: '2.1.0'
}
}
buildInfo() { version: '2.5.0', distributionKind: 'compiled', buildArch: 'x64', buildPlatform: 'linux', buildTarget: 'linux-x64-openssl3', buildTime: '2025-04-08T13:07:57.160Z', gitVersion: '2b03591a8cde3171c86f11d4217352266f1b1a9c', nodeVersion: 'v20.19.0', opensslVersion: '3.2.4', sharedOpenssl: true, runtimeArch: 'x64', runtimePlatform: 'linux', runtimeGlibcVersion: '2.40', deps: { nodeDriverVersion: '6.14.2', libmongocryptVersion: '1.13.0', libmongocryptNodeBindingsVersion: '6.3.0', kerberosVersion: '2.1.0' } }
-
2
-
None
-
Developer Tools
Problem Statement/Rationale
BSON's Long type constructor does not warn the user about loss of precision when used without a string input.
> Long(8589869056) Long('4294901760')
Instead, the NumberLong helper emits a warning when called with the same value.
> NumberLong(8589869056) Warning: NumberLong: specifying a number as argument is deprecated and may lead to loss of precision, pass a string instead Long('8589869056')
Long contructor should behave in the same way because the shell provides an interactive session where warnings are, usually, seen by users.
As an example of consistent behaviour, you can see the Decimal128 contructor and the NumberDecimal helper.
> NumberDecimal(8589869056)
Warning: NumberDecimal: specifying a number as argument is deprecated and may lead to loss of precision, pass a string instead
Decimal128('8589869056')
> Decimal128(8589869056) BSONError: Decimal128 must take a Buffer or string
Steps to Reproduce
Just call Long(8589869056) in the mongo shell.
Expected Results
A warning or an error.