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

distinct command should validate input

    • 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.

            Assignee:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: