summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorNikita Lapkov <nikita.lapkov@mongodb.com>2020-08-18 11:37:15 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-09 11:30:04 +0000
commitd7a970f6b1d87fc4c3754cd53f0ea4ea6bd7caf6 (patch)
tree85e536af0fe399a75031447b46f5b43e494d5f13 /src/mongo
parent39c200878284912f19553901a6fea4b31531a899 (diff)
downloadmongo-d7a970f6b1d87fc4c3754cd53f0ea4ea6bd7caf6.tar.gz
SERVER-26726 Check number of arguments for createIndex, createIndexes and ensureIndex shell commands
(cherry picked from commit be07da4bd6dd394947236857f5510a7ba9c3b0a4)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/shell/collection.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js
index 00143600595..b4b1ac23052 100644
--- a/src/mongo/shell/collection.js
+++ b/src/mongo/shell/collection.js
@@ -616,10 +616,18 @@ DBCollection.prototype._indexSpec = function(keys, options) {
};
DBCollection.prototype.createIndex = function(keys, options) {
+ if (arguments.length > 2) {
+ throw new Error("createIndex accepts up to 2 arguments");
+ }
+
return this.createIndexes([keys], options);
};
DBCollection.prototype.createIndexes = function(keys, options) {
+ if (arguments.length > 2) {
+ throw new Error("createIndexes accepts up to 2 arguments");
+ }
+
if (!Array.isArray(keys)) {
throw new Error("createIndexes first argument should be an array");
}
@@ -653,6 +661,10 @@ DBCollection.prototype.createIndexes = function(keys, options) {
};
DBCollection.prototype.ensureIndex = function(keys, options) {
+ if (arguments.length > 2) {
+ throw new Error("ensureIndex accepts up to 2 arguments");
+ }
+
var result = this.createIndex(keys, options);
if (this.getMongo().writeMode() != "legacy") {