diff options
author | Randolph Tan <randolph@10gen.com> | 2014-01-14 14:09:42 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-02-28 16:26:33 -0500 |
commit | 5595b945603b0712c537787e31e6da661c424fee (patch) | |
tree | 90945ee3fe4931032f3af2d397bb755fbf5d30ef /jstests/core/arrayfind6.js | |
parent | cd62080dcb036e83f8fca6d68d9bcab67bf7a21c (diff) | |
download | mongo-5595b945603b0712c537787e31e6da661c424fee.tar.gz |
SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
Diffstat (limited to 'jstests/core/arrayfind6.js')
-rw-r--r-- | jstests/core/arrayfind6.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/core/arrayfind6.js b/jstests/core/arrayfind6.js new file mode 100644 index 00000000000..f4531cea96a --- /dev/null +++ b/jstests/core/arrayfind6.js @@ -0,0 +1,26 @@ +// Check index bound determination for $not:$elemMatch queries. SERVER-5740 + +t = db.jstests_arrayfind6; +t.drop(); + +t.save( { a:[ { b:1, c:2 } ] } ); + +function checkElemMatchMatches() { + assert.eq( 1, t.count( { a:{ $elemMatch:{ b:1, c:2 } } } ) ); + assert.eq( 0, t.count( { a:{ $not:{ $elemMatch:{ b:1, c:2 } } } } ) ); + assert.eq( 1, t.count( { a:{ $not:{ $elemMatch:{ b:1, c:3 } } } } ) ); + assert.eq( 1, t.count( { a:{ $not:{ $elemMatch:{ b:{ $ne:1 }, c:3 } } } } ) ); + // Index bounds must be determined for $not:$elemMatch, not $not:$ne. In this case if index + // bounds are determined for $not:$ne, the a.b index will be constrained to the interval [2,2] + // and the saved document will not be matched as it should. + assert.eq( 1, t.count( { a:{ $not:{ $elemMatch:{ b:{ $ne:2 }, c:3 } } } } ) ); +} + +checkElemMatchMatches(); +t.ensureIndex( { 'a.b':1 } ); +checkElemMatchMatches(); + +// We currently never use an index for negations of +// ELEM_MATCH_OBJECT expressions. +var explain = t.find( { a:{ $not:{ $elemMatch:{ b:{ $ne:2 }, c:3 } } } } ).explain(); +assert.eq( "BasicCursor", explain.cursor ); |