diff options
author | Aaron <aaron@10gen.com> | 2011-04-25 11:24:06 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-04-25 13:29:50 -0700 |
commit | 870fedc9e1dea57532d109782b2a31378b32f16c (patch) | |
tree | 495df7220ab5a14e620f4ecc3aac3ae997f66cd7 /jstests/indexo.js | |
parent | f799371da9b38f65b68abec09d4b9738fe6d1c66 (diff) | |
download | mongo-870fedc9e1dea57532d109782b2a31378b32f16c.tar.gz |
SERVER-958 tests
Diffstat (limited to 'jstests/indexo.js')
-rw-r--r-- | jstests/indexo.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/jstests/indexo.js b/jstests/indexo.js new file mode 100644 index 00000000000..e50c099de50 --- /dev/null +++ b/jstests/indexo.js @@ -0,0 +1,32 @@ +// Check that dummy basic cursors work correctly SERVER-958. + +t = db.jstests_indexo; +t.drop(); + +function checkDummyCursor( explain ) { + assert.eq( "BasicCursor", explain.cursor ); + assert.eq( 0, explain.nscanned ); + assert.eq( 0, explain.n ); +} + +t.save( {a:1} ); + +t.ensureIndex( {a:1} ); + +// Match is impossible, so no documents should be scanned. +checkDummyCursor( t.find( {a:{$gt:5,$lt:0}} ).explain() ); + +t.drop(); +checkDummyCursor( t.find( {a:1} ).explain() ); + +t.save( {a:1} ); +t.ensureIndex( {a:1} ); +checkDummyCursor( t.find( {$or:[{a:{$gt:5,$lt:0}},{a:1}]} ).explain().clauses[ 0 ] ); + +t.drop(); +t.save( {a:5,b:[1,2]} ); +t.ensureIndex( {a:1,b:1} ); +t.ensureIndex( {a:1} ); +// The first clause will use index {a:1,b:1} with the current implementation. +// The second clause has no valid values for index {a:1} so it will use a dummy cursor. +checkDummyCursor( t.find( {$or:[{b:{$exists:true},a:{$gt:4}},{a:{$lt:6,$gt:4}}]} ).explain().clauses[ 1 ] ); |