Permalink
Browse files

SERVER-4150 add some additional return key tests

  • Loading branch information...
1 parent 6dc906b commit 2f216fc5fa7e6cc83e89bcb306ec7e7100da7197 @astaple astaple committed Feb 19, 2012
Showing with 16 additions and 2 deletions.
  1. +16 −2 jstests/index_diag.js
View
@@ -38,9 +38,23 @@ assert.eq( r( xs ) , t.find().hint( { x : 1 } )._addSpecial( "$returnKey" , true
// SERVER-4981
t.ensureIndex( { _id : 1 , x : 1 } );
+assert.eq( all ,
+ t.find().hint( { _id : 1 , x : 1 } )._addSpecial( "$returnKey" , true ).toArray()
+ )
assert.eq( r( all ) ,
- t.find().hint( { _id : 1 , x : 1 } ).sort( { x : 1 } )._addSpecial( "$returnKey" , true ).toArray()
+ t.find().hint( { _id : 1 , x : 1 } ).sort( { x : 1 } )
+ ._addSpecial( "$returnKey" , true ).toArray()
)
-assert.eq( [ {}, {}, {} ],
+// Descriptive test that a query involving multiple plans may return keys from multiple indexes.
+t.dropIndex( { _id : 1 , x : 1 } );
+ret =
+t.find( { _id : { $gt : -10 }, x : { $gt : -10 } } )._addSpecial( "$returnKey" , true ).toArray()
+keys = {};
+for( i in ret ) {
+ Object.extend( keys, ret[ i ] );
+}
+assert.eq( [ "_id" , "x" ], Object.keySet( keys ).sort() );
+
+assert.eq( [ {} , {} , {} ],
t.find().hint( { $natural : 1 } )._addSpecial( "$returnKey" , true ).toArray() )

0 comments on commit 2f216fc

Please sign in to comment.