summaryrefslogtreecommitdiff
path: root/src/mongo/shell/explainable.js
diff options
context:
space:
mode:
author“Dandan <dandanlin.l@gmail.com>2018-02-19 15:51:03 -0500
committerCharlie Swanson <charlie.swanson@mongodb.com>2018-03-05 15:06:59 -0500
commit120aed6254ff814a351f99d4e243a1510286ffb0 (patch)
tree424e7693ec5f66bc14a9211c2f6e8a527f402b0c /src/mongo/shell/explainable.js
parentf939177a8dfc341e50f047977ab4265e76edce0d (diff)
downloadmongo-120aed6254ff814a351f99d4e243a1510286ffb0.tar.gz
SERVER-32300 Explainable.aggregate should not modify options argument.
Closes #1219 Signed-off-by: Charlie Swanson <charlie.swanson@mongodb.com>
Diffstat (limited to 'src/mongo/shell/explainable.js')
-rw-r--r--src/mongo/shell/explainable.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mongo/shell/explainable.js b/src/mongo/shell/explainable.js
index 795326ab9d0..67348a7e8e9 100644
--- a/src/mongo/shell/explainable.js
+++ b/src/mongo/shell/explainable.js
@@ -100,22 +100,22 @@ var Explainable = (function() {
}
// Add the explain option.
- extraOpts = extraOpts || {};
+ let extraOptsCopy = Object.extend({}, (extraOpts || {}));
// For compatibility with 3.4 and older versions, when the verbosity is "queryPlanner",
// we use the explain option to the aggregate command. Otherwise we issue an explain
// command wrapping the agg command, which is supported by newer versions of the server.
if (this._verbosity === "queryPlanner") {
- extraOpts.explain = true;
- return this._collection.aggregate(pipeline, extraOpts);
+ extraOptsCopy.explain = true;
+ return this._collection.aggregate(pipeline, extraOptsCopy);
} else {
// The aggregate command requires a cursor field.
- if (!extraOpts.hasOwnProperty("cursor")) {
- extraOpts = Object.extend(extraOpts, {cursor: {}});
+ if (!extraOptsCopy.hasOwnProperty("cursor")) {
+ extraOptsCopy = Object.extend(extraOptsCopy, {cursor: {}});
}
let aggCmd = Object.extend(
- {"aggregate": this._collection.getName(), "pipeline": pipeline}, extraOpts);
+ {"aggregate": this._collection.getName(), "pipeline": pipeline}, extraOptsCopy);
let explainCmd = {"explain": aggCmd, "verbosity": this._verbosity};
let explainResult = this._collection.runReadCommand(explainCmd);
return throwOrReturn(explainResult);