diff options
author | Mathias Stearn <mathias@10gen.com> | 2010-07-16 09:28:21 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2010-07-16 09:28:21 -0400 |
commit | 3a044ab7e9966c05fd5984b4e6438e1e38a4099e (patch) | |
tree | eda56508cfebff1ddb339d16d56101ae988646f0 /jstests/sharding/key_many.js | |
parent | 326babfe6dc5180aef37ab9139e7dc32412c00f5 (diff) | |
download | mongo-3a044ab7e9966c05fd5984b4e6438e1e38a4099e.tar.gz |
Compound key sharding test now passes SERVER-951
Diffstat (limited to 'jstests/sharding/key_many.js')
-rw-r--r-- | jstests/sharding/key_many.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/jstests/sharding/key_many.js b/jstests/sharding/key_many.js index c94e51f182f..21f37b7f490 100644 --- a/jstests/sharding/key_many.js +++ b/jstests/sharding/key_many.js @@ -10,7 +10,7 @@ types = [ { name : "embedded 1" , values : [ "allan" , "bob" , "eliot" , "joe" , "mark" , "sara" ] , keyfield : "a.b" } , { name : "embedded 2" , values : [ "allan" , "bob" , "eliot" , "joe" , "mark" , "sara" ] , keyfield : "a.b.c" } , { name : "object" , values : [ {a:1, b:1.2}, {a:1, b:3.5}, {a:1, b:4.5}, {a:2, b:1.2}, {a:2, b:3.5}, {a:2, b:4.5} ] , keyfield : "o" } , - //{ name : "compound" , values : [ {a:1, b:1.2}, {a:1, b:3.5}, {a:1, b:4.5}, {a:2, b:1.2}, {a:2, b:3.5}, {a:2, b:4.5} ] , keyfield : "o" , compound : true } , + { name : "compound" , values : [ {a:1, b:1.2}, {a:1, b:3.5}, {a:1, b:4.5}, {a:2, b:1.2}, {a:2, b:3.5}, {a:2, b:4.5} ] , keyfield : "o" , compound : true } , { name : "oid_id" , values : [ ObjectId() , ObjectId() , ObjectId() , ObjectId() , ObjectId() , ObjectId() ] , keyfield : "_id" } , { name : "oid_other" , values : [ ObjectId() , ObjectId() , ObjectId() , ObjectId() , ObjectId() , ObjectId() ] , keyfield : "o" } , ] @@ -54,6 +54,15 @@ function makeObject( v ){ return o; } +function makeInQuery(){ + if (curT.compound){ + // cheating a bit... + return {'o.a': {$in: [1,2]}}; + } else { + return makeObjectDotted({$in: curT.values}); + } +} + function getKey( o ){ var keys = curT.keyfield.split('.'); for(var i=0; i<keys.length; i++){ @@ -112,7 +121,7 @@ for ( var i=0; i<types.length; i++ ){ assert.eq( 6 , count , curT.name + " total count with stats() sum" ); assert.eq( curT.values , c.find().sort( makeObjectDotted( 1 ) ).toArray().map( getKey ) , curT.name + " sort 1" ); - assert.eq( curT.values , c.find(makeObjectDotted({$in: curT.values})).sort( makeObjectDotted( 1 ) ).toArray().map( getKey ) , curT.name + " sort 1" ); + assert.eq( curT.values , c.find(makeInQuery()).sort( makeObjectDotted( 1 ) ).toArray().map( getKey ) , curT.name + " sort 1 - $in" ); assert.eq( curT.values.reverse() , c.find().sort( makeObjectDotted( -1 ) ).toArray().map( getKey ) , curT.name + " sort 2" ); |