-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: Internal Code, Querying, Shell
-
Minor Change
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
Currently if you mistakenly send a non-string as the key field no error is generated. Both the command and shell helper should be checking this.
> db.dbref.find({"ref.$ref":"extra"}) { "_id" : 1, "ref" : DBRef("extra", 2) } > db.dbref.distinct({"ref.$ref":"extra"}) // should generate an error [ ]
The command turns this into the key spec {"":1} because of "cmdObj["key"].valuestrsafe();" returning "" for non strings.
In both places we just need to make sure the arg is a string, or error.
Likewise the query option should also be validated since anything other than embedded doc will result in the value being ignored and replaced by the empty query/doc.