Today the logic behind ensureNsNotCommand is a bit problematic.
We call `serialize` on a NamespaceString object just to parse the string and check for a `$`. We should refactor that so we do not have to allocated a new `std::string` just to parse the NamespaceString data.
The name of the method is also problematic.
This documentation page shows us that there is a restriction on collection name not including a $ , and it appears that this is where we actually do that validation. Its really like the function wants to be called ensureValidQueryNamespace and its implementation should be like:
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Invalid collection name specified '" << nss.toStringForErrorMsg(),
!nss.isCommand() && isValidCollection(nss.coll()) && nss != NamespaceString::kLocalOplogDollarMain));
- related to
-
SERVER-81288 Make NamespaceStringUtil::serialize no longer use default serialization context
- Closed