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

BinData requires constructor in shell, unlike HexData

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Done
    • 2.0.0
    • 2.1.0
    • JavaScript, Shell
    • Mac OSX, linux (Centos 5.6)
    • ALL

    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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: