[SERVER-28847] ensure all subclasses of Command override parseNs() if they have a non-default command format Created: 18/Apr/17  Updated: 06/Dec/22  Resolved: 05/May/17

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: 3.5.6
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: Backlog - Query Team (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query
Participants:

 Description   

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.



 Comments   
Comment by Ian Whalen (Inactive) [ 05/May/17 ]

Not convinced that this is the solution we want, and we probably won't be able to do this at any point even in the medium-term future, so Won't Fixing.

Comment by Esha Maharishi (Inactive) [ 21/Apr/17 ]

Cool, also note that ExplainCmd was fixed by https://github.com/mongodb/mongo/commit/4354125dd663c7b6b0ba853a70c98dc786f9385a#diff-d072425be17d85e70f10e8a02d85875eR86-R98.

Generated at Thu Feb 08 04:19:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.