diff options
author | Arun Banala <arun.banala@10gen.com> | 2019-10-30 15:49:38 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-30 15:49:38 +0000 |
commit | 9034b668f90feb5a0f1ac9fd2a8714ecbe4cd057 (patch) | |
tree | 002e9ca071c0a7c0c0435059b90d2db6372dcced /jstests | |
parent | edf22ddd2963839b50a658c43532e1742caeefc2 (diff) | |
download | mongo-9034b668f90feb5a0f1ac9fd2a8714ecbe4cd057.tar.gz |
SERVER-44050 Arrays are not correctly rejected during key generation for 'hashed' indexes
(cherry picked from commit 888f7e6fc10ccb999be203b8cbad4dbe19d0a5d2)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/hashindex1.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/jstests/core/hashindex1.js b/jstests/core/hashindex1.js index 93986ecfd5e..09a1e1f7b47 100644 --- a/jstests/core/hashindex1.js +++ b/jstests/core/hashindex1.js @@ -87,3 +87,13 @@ var total = t.find().hint({"_id": 1}).toArray().length; var totala = t.find().hint(goodspec).toArray().length; assert.eq(total, totala, "non-sparse index has wrong total"); assert.lt(totalb, totala, "sparse index should have smaller total"); + +// Test that having arrays along the path of the index is not allowed. +assert.commandWorked(t.createIndex({"field1.field2.0.field4": "hashed"})); +assert.writeErrorWithCode(t.insert({field1: []}), 16766); +assert.writeErrorWithCode(t.insert({field1: {field2: []}}), 16766); +assert.writeErrorWithCode(t.insert({field1: {field2: {0: []}}}), 16766); +assert.writeErrorWithCode(t.insert({field1: [{field2: {0: []}}]}), 16766); +assert.writeErrorWithCode(t.insert({field1: {field2: {0: {field4: []}}}}), 16766); +assert.writeOK(t.insert({field1: {field2: {0: {otherField: []}}}})); +assert.writeOK(t.insert({field1: {field2: {0: {field4: 1}}}})); |