diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-11-27 10:35:45 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2013-12-03 21:24:55 -0500 |
commit | cb7bea77aa5796af6016e3b8e0d725f1e4fb1d14 (patch) | |
tree | 15040f404a61ea8dab6033005f511a3a922be34b /jstests/nestedobj1.js | |
parent | 22a03afae8a1a3b9e9218e8e9985f5bfb8d9ac04 (diff) | |
download | mongo-cb7bea77aa5796af6016e3b8e0d725f1e4fb1d14.tar.gz |
SERVER-5290: when trying to insert a document with a key too large to index, fail the insert
will also prevent creating an index on a field that is too large
that is only done for secondaries
Diffstat (limited to 'jstests/nestedobj1.js')
-rw-r--r-- | jstests/nestedobj1.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/jstests/nestedobj1.js b/jstests/nestedobj1.js index 02dc5f085c4..45ef0c530d4 100644 --- a/jstests/nestedobj1.js +++ b/jstests/nestedobj1.js @@ -12,17 +12,19 @@ function makeNestObj(depth){ t = db.objNestTest; t.drop(); -t.ensureIndex({a:1}); -nestedObj = makeNestObj(300); +t.ensureIndex({a:1}); -t.insert( { tst : "test1", a : nestedObj }, true ); -t.insert( { tst : "test2", a : nestedObj }, true ); -t.insert( { tst : "test3", a : nestedObj }, true ); +n = 1; +while ( true ) { + var before = t.count(); + t.insert( { _id : n, a : makeNestObj(n) } ); + var after = t.count(); + if ( before == after ) + break; + n++; +} -assert.eq(3, t.count(), "records in collection"); -assert.eq(1, t.find({tst : "test2"}).count(), "find test"); +assert( n > 30, "not enough n: " + n ); -//make sure index insertion failed (nesting must be large enough) -assert.eq(0, t.find().hint({a:1}).explain().n, "index not empty"); -print("Test succeeded!") +assert.eq( t.count(), t.find( { _id : { $gt : 0 } } ).hint( { a : 1 } ).itcount() ); |