Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4093

BinData requires constructor in shell, unlike HexData

    • ALL

      > 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            mikeatkins Mike Atkins
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: