ensure all subclasses of Command override parseNs() if they have a non-default command format

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.5.6
    • Component/s: Internal Code
    • None
    • Query
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The default parseNs(), defined in the base class Command, assumes the first element in the cmdObj holds the collection name. If that element is not a string, it assumes there's no collection. This works for commands of the form {find:"foo"}:

      string Command::parseNs(const string& dbname, const BSONObj& cmdObj) const {
          BSONElement first = cmdObj.firstElement();
          if (first.type() != mongo::String)
              return dbname;
      
          return str::stream() << dbname << '.' << cmdObj.firstElement().valueStringData();
      }
      

      But explain commands, for example, which use the format {explain:{find:"foo"}}, should override parseNs().

      Assigning to backlog-server-platform, but feel free to pass this to a better home if there is one.

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: