summaryrefslogtreecommitdiff
path: root/jstests/core/create_indexes.js
diff options
context:
space:
mode:
authorXin Hao Zhang <xinhao.zhang@mongodb.com>2019-06-03 17:54:21 -0400
committerXin Hao Zhang <xinhao.zhang@mongodb.com>2019-06-05 14:10:20 -0400
commitd5d674930f1c67f6c87d73715f82f608668d72fa (patch)
treefa68f6c6bc6252bfdce7123b945078f10af96bff /jstests/core/create_indexes.js
parentd8e2c4748fda6fc24ea0d1bb1541ea9c66f5e1cf (diff)
downloadmongo-d5d674930f1c67f6c87d73715f82f608668d72fa.tar.gz
SERVER-41263 Disallow empty string in index key type
Diffstat (limited to 'jstests/core/create_indexes.js')
-rw-r--r--jstests/core/create_indexes.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/jstests/core/create_indexes.js b/jstests/core/create_indexes.js
index 45db4c9ef76..c5e7d46de97 100644
--- a/jstests/core/create_indexes.js
+++ b/jstests/core/create_indexes.js
@@ -166,6 +166,10 @@
res = t.runCommand('createIndexes', {indexes: [{key: {star: 1}, name: '*'}]});
assert.commandFailedWithCode(res, ErrorCodes.BadValue);
+ // Test that index creation fails with an index value of empty string.
+ res = t.runCommand('createIndexes', {indexes: [{key: {f: ""}, name: 'f_1'}]});
+ assert.commandFailedWithCode(res, ErrorCodes.CannotCreateIndex);
+
// Test that user is not allowed to create indexes in config.transactions.
var configDB = db.getSiblingDB('config');
res = configDB.runCommand(