[SERVER-4093] BinData requires constructor in shell, unlike HexData Created: 18/Oct/11  Updated: 11/Jul/16  Resolved: 20/Feb/12

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: 2.0.0
Fix Version/s: 2.1.0

Type: Bug Priority: Minor - P4
Reporter: Mike Atkins Assignee: Unassigned
Resolution: Done Votes: 1
Labels: bindata, javascript, shell
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OSX, linux (Centos 5.6)


Issue Links:
Depends
Duplicate
is duplicated by SERVER-5203 find BinData without new Shell Closed
Related
Operating System: ALL
Participants:

 Description   

> db.bindata.insert(

{ foo: BinData(0,"gpJOnIbX+ZJkAwTZpAw=")}

)
> db.bindata.find()

{ "_id" : ObjectId("4e9d87aa5825b60b637815a6"), "foo" : null }

so BinData(0,"gpJOnIbX+ZJkAwTZpAw=")produces null..

> db.bindata.insert(

{ foo: HexData(0,"5555")}

)
> db.bindata.find()

{ "_id" : ObjectId("4e9d87aa5825b60b637815a6"), "foo" : null } { "_id" : ObjectId("4e9d87d15825b60b637815a7"), "foo" : BinData(0,"VVU=") }

whereas HexData(0, "5555") produces a non-null value, as expected.
If I use the new keyword with BinData, it does what I expect:

> db.bindata.insert(

{ foo: new BinData(0,"gpJOnIbX+ZJkAwTZpAw=")}

)
> db.bindata.find()

{ "_id" : ObjectId("4e9d87aa5825b60b637815a6"), "foo" : null } { "_id" : ObjectId("4e9d87d15825b60b637815a7"), "foo" : BinData(0,"VVU=") } { "_id" : ObjectId("4e9d87e15825b60b637815a8"), "foo" : BinData(0,"gpJOnIbX+ZJkAwTZpAw=") }

and..

> db.bindata.find(

{foo: new BinData(0,"gpJOnIbX+ZJkAwTZpAw=")}

)

{ "_id" : ObjectId("4e9d87e15825b60b637815a8"), "foo" : BinData(0,"gpJOnIbX+ZJkAwTZpAw=") }

so, basically "new" needed with BinData, but not HexData.



 Comments   
Comment by Scott Hernandez (Inactive) [ 20/Feb/12 ]

> version()
version: 2.1.0
> BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")
BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")
> new BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")
BinData(0,"AQAAAAEBAAVlbl9VSwAAAAAAAAhv")

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