Details
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(
,
{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(
, {$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(
,
{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 }>