Error is produced to the screen, but command executes anyway.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • None
    • Affects Version/s: 2.0.7
    • Component/s: Shell, Usability
    • None
    • Environment:
      Windows XP Professional, Service Pack 3, 32-bit
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      An error is shown when attempting to use help() function in the wrong context: "Wed Oct 31 00:38:51 TypeError: d.update(

      {'for':"ac3"}

      , {$inc:{price:2}}) has no properties (shell):1"
      getLastError() returns null and command executes anyway, even though the syntax is not correct for the whole command.

      Expected behavior: fail the query if it has incorrect syntax.

      Here is an example in mongo shell:
      > d
      pcat.products
      > d.find(

      {for: "ac3"}

      ,

      {price:1}

      ).sort({_id:1}).pretty()

      { "_id" : ObjectId("507d95d5719dbef170f15bf9"), "price" : 21 } { "_id" : ObjectId("507d95d5719dbef170f15bfb"), "price" : 42 } { "_id" : ObjectId("507d95d5719dbef170f15bfc"), "price" : 30.5 } { "_id" : ObjectId("507d95d5719dbef170f15bfd"), "price" : 14 }

      > d.update(

      {for: "ac3"}

      , {$inc: {price: 2}} ).help()
      Wed Oct 31 00:38:51 TypeError: d.update(

      {'for':"ac3"}

      , {$inc:{price:2}}) has no
      properties (shell):1
      > db.getLastError()
      null
      > db.getLastErrorObj()
      {
      "updatedExisting" : true,
      "n" : 1,
      "connectionId" : 4,
      "err" : null,
      "ok" : 1
      }
      > d.find(

      {for: "ac3"}

      ,

      {price:1}

      ).sort({_id:1}).pretty()

      { "_id" : ObjectId("507d95d5719dbef170f15bf9"), "price" : 21 } { "_id" : ObjectId("507d95d5719dbef170f15bfb"), "price" : 42 } { "_id" : ObjectId("507d95d5719dbef170f15bfc"), "price" : 32.5 } { "_id" : ObjectId("507d95d5719dbef170f15bfd"), "price" : 14 }

      >

            Assignee:
            Unassigned
            Reporter:
            dabest1
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: