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

BinData requires constructor in shell, unlike HexData

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1.0
    • Component/s: JavaScript, Shell
    • Environment:
      Mac OSX, linux (Centos 5.6)
    • Operating System:
      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

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

                Dates

                Created:
                Updated:
                Resolved: