Details
-
Bug
-
Resolution: Done
-
Minor - P4
-
None
-
2.0.4, 2.2.0
-
None
-
None
-
Centos 6.3 x64 running MongoDB 2.2.0,
Centos 5.8 x64 running MongoDB 2.0.4
-
ALL
Description
Found an issue with NumberLong when trying to work with the value 0. Inside a Map-Reduce function, I was trying to get a sum of values that included zero. Some of the resulting documents ended up with a value of null. After a long time of hunting, limited it down the fact that NumberLong(0) would kill a function if trying to convert to an integer (NumberLong.toNumber()) with no stack traces or log entries.
I would also note that I could find close to no documentation for NumberLong in the wiki.
Here's a test case that isolates the issue for me:
var test = function() {
|
print('NumberLong(0) test');
|
var test1 = NumberLong(0);
|
print(test1.toNumber());
|
print('Unreached 1');
|
// Also fails
|
print(test1 + 1);
|
print('Unreached 2');
|
return {'some' : 'result'};
|
};
|
test();
|
Expected (when run from the shell):
NumberLong(0) test
|
0
|
Unreached 1
|
1
|
Unreached 2
|
{ "some" : "result" }
|
Result:
NumberLong(0) test
|