diff options
author | Hirday Gupta <hirday.gupta@mongodb.com> | 2020-06-24 16:49:07 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-06 18:24:25 +0000 |
commit | e199a343576be60a13154cf771e7a4d623e1d6c0 (patch) | |
tree | 88166718355e0ab7d5f43f554144feb085b181ec | |
parent | 62c839f517192b3ffe84f1ed7694aa22d62acbcd (diff) | |
download | mongo-e199a343576be60a13154cf771e7a4d623e1d6c0.tar.gz |
SERVER-48244 remove shell-side explain string validation
(cherry picked from commit c76a5544eb4423c7dbca6862fddf9371ce999f6f)
-rw-r--r-- | jstests/core/explain_find.js | 15 | ||||
-rw-r--r-- | jstests/core/explain_shell_helpers.js | 8 | ||||
-rw-r--r-- | src/mongo/shell/explainable.js | 8 |
3 files changed, 16 insertions, 15 deletions
diff --git a/jstests/core/explain_find.js b/jstests/core/explain_find.js index 87174e99a62..0d9e1eef95b 100644 --- a/jstests/core/explain_find.js +++ b/jstests/core/explain_find.js @@ -1,5 +1,8 @@ // Tests for explaining find through the explain command. +(function() { +"use strict"; + var collName = "jstests_explain_find"; var t = db[collName]; t.drop(); @@ -30,3 +33,15 @@ if (!db.getMongo().useReadCommands()) { assert.eq(1, explain.executionStats.nReturned); assert("allPlansExecution" in explain.executionStats); } + +// Invalid verbosity string. +let error = assert.throws(function() { + t.explain("foobar").find().finish(); +}); +assert.commandFailedWithCode(error, ErrorCodes.FailedToParse); + +error = assert.throws(function() { + t.find().explain("foobar"); +}); +assert.commandFailedWithCode(error, ErrorCodes.FailedToParse); +}());
\ No newline at end of file diff --git a/jstests/core/explain_shell_helpers.js b/jstests/core/explain_shell_helpers.js index 910c6947e11..b5de517a4cc 100644 --- a/jstests/core/explain_shell_helpers.js +++ b/jstests/core/explain_shell_helpers.js @@ -416,14 +416,6 @@ assert.eq(10, t.count()); // Error cases. // -// Invalid verbosity string. -assert.throws(function() { - t.explain("foobar").find().finish(); -}); -assert.throws(function() { - t.find().explain("foobar"); -}); - // Can't explain an update without a query. assert.throws(function() { t.explain().update(); diff --git a/src/mongo/shell/explainable.js b/src/mongo/shell/explainable.js index 67348a7e8e9..ae4f918f264 100644 --- a/src/mongo/shell/explainable.js +++ b/src/mongo/shell/explainable.js @@ -4,7 +4,6 @@ // var Explainable = (function() { - var parseVerbosity = function(verbosity) { // Truthy non-strings are interpreted as "allPlansExecution" verbosity. if (verbosity && (typeof verbosity !== "string")) { @@ -16,12 +15,7 @@ var Explainable = (function() { return "queryPlanner"; } - // If we're here, then the verbosity is a string. We reject invalid strings. - if (verbosity !== "queryPlanner" && verbosity !== "executionStats" && - verbosity !== "allPlansExecution") { - throw Error("explain verbosity must be one of {" + "'queryPlanner'," + - "'executionStats'," + "'allPlansExecution'}"); - } + // All verbosity strings are passed through. Server validates if it is a known option. return verbosity; }; |