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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.0.7
    • Shell, Usability
    • None
    • Windows XP Professional, Service Pack 3, 32-bit
    • ALL

    Description

      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 }

      >

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: