diff options
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/indexu.js | 7 |
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)); |