diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2018-10-09 16:12:21 +0000 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2018-10-11 03:42:54 +0000 |
commit | 2f4b5918497b09a226a3ec5dcff930edd52ea1e9 (patch) | |
tree | 29cf994491b4042d819f9e19e05b3ff1684b9d3e /src/mongo/db/commands/list_databases.cpp | |
parent | 8dab2485c1badc2fd09b84667b4dcfc8b53fef63 (diff) | |
download | mongo-r4.1.4.tar.gz |
SERVER-37526 IDLify listDatabases commandr4.1.4
Diffstat (limited to 'src/mongo/db/commands/list_databases.cpp')
-rw-r--r-- | src/mongo/db/commands/list_databases.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp index d736b4b5737..59e29c5f600 100644 --- a/src/mongo/db/commands/list_databases.cpp +++ b/src/mongo/db/commands/list_databases.cpp @@ -35,6 +35,7 @@ #include "mongo/db/catalog_raii.h" #include "mongo/db/client.h" #include "mongo/db/commands.h" +#include "mongo/db/commands/list_databases_gen.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/matcher/expression.h" #include "mongo/db/operation_context.h" @@ -87,27 +88,24 @@ public: bool run(OperationContext* opCtx, const string& dbname, - const BSONObj& jsobj, + const BSONObj& cmdObj, BSONObjBuilder& result) final { + IDLParserErrorContext ctx("listDatabases"); + auto cmd = ListDatabasesCommand::parse(ctx, cmdObj); + + const bool nameOnly = cmd.getNameOnly(); + // Parse the filter. std::unique_ptr<MatchExpression> filter; - if (auto filterElt = jsobj[kFilterField]) { - if (filterElt.type() != BSONType::Object) { - uasserted(ErrorCodes::TypeMismatch, - str::stream() << "Field '" << kFilterField - << "' must be of type Object in: " - << jsobj); - } + if (auto filterObj = cmd.getFilter()) { // The collator is null because database metadata objects are compared using simple // binary comparison. const CollatorInterface* collator = nullptr; boost::intrusive_ptr<ExpressionContext> expCtx(new ExpressionContext(opCtx, collator)); - auto statusWithMatcher = - MatchExpressionParser::parse(filterElt.Obj(), std::move(expCtx)); - uassertStatusOK(statusWithMatcher.getStatus()); - filter = std::move(statusWithMatcher.getValue()); + auto matcher = + uassertStatusOK(MatchExpressionParser::parse(filterObj.get(), std::move(expCtx))); + filter = std::move(matcher); } - bool nameOnly = jsobj[kNameOnlyField].trueValue(); vector<string> dbNames; StorageEngine* storageEngine = getGlobalServiceContext()->getStorageEngine(); |