[SERVER-8885] BinData type issues with db.eval and mapReduce Created: 06/Mar/13  Updated: 11/Jul/16  Resolved: 08/Mar/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 2.4.0-rc2
Fix Version/s: 2.4.0-rc1

Type: Bug Priority: Minor - P4
Reporter: Shaun Verch Assignee: Ben Becker
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

mongos> BinData()
BinData(0,"undefined")
mongos> eval("BinData()")
BinData(0,"undefined")
mongos> db.eval("BinData()")
Wed Mar  6 15:49:33.060 JavaScript execution failed: {
	"errmsg" : "exception: cannot convert native function to BSON",
	"code" : 16716,
	"ok" : 0
} at src/mongo/shell/db.js:L567
mongos> 

However, this works:

mongos> db.eval("var b = BinData(); return;")
null

Seems like the same issue with mapReduce, but only when emitted in the map function and called with no arguments.

mongos> m = function () { emit("test",BinData()) }
function () { emit("test",BinData()) }
mongos> r = function (k, v) { return { "test" : 1 } }
function (k, v) { return { "test" : 1 } }
mongos> db.mrtest.mapReduce(m,r,{out:"mrtest_out"})
Thu Mar  7 13:01:57.435 JavaScript execution failed: map reduce failed:{
	"errmsg" : "exception: JavaScript execution failed: Error: cannot convert native function to BSON near 'tion () { emit(\"test\"' ",
	"code" : 16722,
	"ok" : 0
} at src/mongo/shell/collection.js:L970
mongos> 



 Comments   
Comment by Ben Becker [ 08/Mar/13 ]

All of these tests pass now. Tested with git version 0893701ad4a183589e08d3e00428b6f1d5a37124.

Generated at Thu Feb 08 03:18:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.