summaryrefslogtreecommitdiff
path: root/jstests/core/indexu.js
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-11-14 20:38:41 +0000
committerevergreen <evergreen@mongodb.com>2019-11-14 20:38:41 +0000
commit3f4312f26e1667826db51a0d2834eb417bb5de2d (patch)
treec745d9c6d63bd3637e2fda99fd4f9162c07db97f /jstests/core/indexu.js
parentd24bae5300d3f6a342f5981f26e4309264aa4cb0 (diff)
downloadmongo-3f4312f26e1667826db51a0d2834eb417bb5de2d.tar.gz
SERVER-44619 truncate message for error code 16746 if too long
Diffstat (limited to 'jstests/core/indexu.js')
-rw-r--r--jstests/core/indexu.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/jstests/core/indexu.js b/jstests/core/indexu.js
index f8b6af7f15d..0e68429eaf7 100644
--- a/jstests/core/indexu.js
+++ b/jstests/core/indexu.js
@@ -6,7 +6,7 @@
t = db.jstests_indexu;
t.drop();
-var dupDoc = {a: [{'0': 1}]}; // There are two 'a.0' fields in this doc.
+var dupDoc = {_id: 0, a: [{'0': 1}]}; // There are two 'a.0' fields in this doc.
var dupDoc2 = {a: [{'1': 1}, 'c']};
var noDupDoc = {a: [{'1': 1}]};
@@ -14,6 +14,11 @@ var noDupDoc = {a: [{'1': 1}]};
assert.commandWorked(t.save(dupDoc));
assert.commandFailed(t.ensureIndex({'a.0': 1}));
+// Test that we can fail gracefully when dupDoc has a large array padded with nulls.
+// Index is based on max padding constant in mongo/db/update/path_support.h
+assert.commandWorked(t.update({_id: 0}, {$set: {'a.1500001': 1}}));
+assert.commandFailedWithCode(t.ensureIndex({'a.0': 1}), 16746);
+
t.remove({});
assert.commandWorked(t.ensureIndex({'a.0': 1}));
assert.writeError(t.save(dupDoc));