summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-05-19 19:44:29 -0400
committerEliot Horowitz <eliot@10gen.com>2013-05-19 19:44:29 -0400
commit705872c7e387f65a15d4c24163627f65b50be21d (patch)
tree1a51544d87bd60b35322eb623d1c1e767645c812 /jstests
parent65c12e6fe156a6e64515a5a6b6ede6bccfb81ca7 (diff)
downloadmongo-705872c7e387f65a15d4c24163627f65b50be21d.tar.gz
SERVER-6400: This switches from MatcherOld to Matcher2
This commit also has all semantic changes encompassed in this switch
Diffstat (limited to 'jstests')
-rw-r--r--jstests/array_match2.js5
-rw-r--r--jstests/arrayfind5.js2
-rw-r--r--jstests/geo_array0.js2
-rw-r--r--jstests/indexv.js2
-rw-r--r--jstests/indexy.js35
-rw-r--r--jstests/null.js12
-rw-r--r--jstests/null2.js45
-rw-r--r--jstests/orh.js4
8 files changed, 62 insertions, 45 deletions
diff --git a/jstests/array_match2.js b/jstests/array_match2.js
index d64ca1b2837..663cdcdeb6e 100644
--- a/jstests/array_match2.js
+++ b/jstests/array_match2.js
@@ -1,4 +1,3 @@
-// Different recursive array match cases SERVER-2898
t = db.jstests_array_match2;
t.drop();
@@ -11,15 +10,11 @@ assert.eq( 1, t.count( {'a.1':5} ) );
t.remove();
// When the array index is not the last field, only one of the match types works.
t.save( {a:[{1:{foo:4}},{foo:5}]} );
-if ( 0 ) { // SERVER-2898
assert.eq( 1, t.count( {'a.1.foo':4} ) );
-}
assert.eq( 1, t.count( {'a.1.foo':5} ) );
// Same issue with the $exists operator
t.remove();
t.save( {a:[{1:{foo:4}},{}]} );
assert.eq( 1, t.count( {'a.1':{$exists:true}} ) );
-if ( 0 ) { // SERVER-2898
assert.eq( 1, t.count( {'a.1.foo':{$exists:true}} ) );
-}
diff --git a/jstests/arrayfind5.js b/jstests/arrayfind5.js
index 083dc0622c8..9ff6e2b8a5f 100644
--- a/jstests/arrayfind5.js
+++ b/jstests/arrayfind5.js
@@ -6,7 +6,7 @@ t.drop();
function check( nullElemMatch ) {
assert.eq( 1, t.find( {'a.b':1} ).itcount() );
assert.eq( 1, t.find( {a:{$elemMatch:{b:1}}} ).itcount() );
- assert.eq( 0, t.find( {'a.b':null} ).itcount() );
+ assert.eq( nullElemMatch ? 1 : 0 , t.find( {'a.b':null} ).itcount() );
assert.eq( nullElemMatch ? 1 : 0, t.find( {a:{$elemMatch:{b:null}}} ).itcount() ); // see SERVER-3377
}
diff --git a/jstests/geo_array0.js b/jstests/geo_array0.js
index ff6fcf015d7..5fe46781d1d 100644
--- a/jstests/geo_array0.js
+++ b/jstests/geo_array0.js
@@ -23,5 +23,5 @@ function test(index) {
assert.eq( 4, t.find( { loc : { $within : { $box : [ [ 45, 45 ], [ 50, 50 ] ] } } } ).count() );
}
-test(false)
+//test(false); // this was removed as part of SERVER-6400
test(true)
diff --git a/jstests/indexv.js b/jstests/indexv.js
index a69ff2a4664..334ec432d74 100644
--- a/jstests/indexv.js
+++ b/jstests/indexv.js
@@ -7,7 +7,7 @@ t.ensureIndex( {'a.b':1} );
t.save( {a:[{},{b:1}]} );
var e = t.find( {'a.b':null} ).explain();
-assert.eq( 0, e.n );
+assert.eq( 1, e.n );
assert.eq( 1, e.nscanned );
t.drop();
diff --git a/jstests/indexy.js b/jstests/indexy.js
deleted file mode 100644
index def63743785..00000000000
--- a/jstests/indexy.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// Null index keys may be generated for documents that do not match null. In particular, for index
-// { 'a.c':1 } the document { a:[ {}, { c:10 } ] } generates index keys { '':null } and { '':10 }.
-// While the query { a:{ $elemMatch:{ c:null } } } has been designated to match this document, the
-// query { 'a.c':null } has been designated to not match this document.
-//
-// Because the above and similar queries do not match the document but do match documents lacking
-// any 'a.c' field (which also generate a { '':null } key), a Matcher is required when it is
-// necessary to select matching documents for these queries. As a result, the fast count in which
-// the matcher is bypassed (SERVER-1752) cannot be used for such queries. The following tests check
-// that the count is calculated correctly in cases where fast count mode should not be applied.
-//
-// SERVER-4529
-
-t = db.jstests_indexy;
-t.drop();
-
-function assertNoMatch( query ) {
- // Check that no results are returned by a find.
- assert.eq( 0, t.find( query ).itcount() );
- // Check that no results are counted by a count.
- assert.eq( 0, t.find( query ).count() );
-}
-
-t.save({a:[{},{c:10}]});
-assertNoMatch( { 'a.c':null } );
-
-t.ensureIndex({'a.c':1});
-// No equality match against null.
-assertNoMatch( { 'a.c':null } );
-// No $in match against null.
-assertNoMatch( { 'a.c':{ $in:[ null ] } } );
-assertNoMatch( { 'a.c':{ $in:[ null, 1 ] } } );
-// No match for a query generating the field range [[ minkey, {} ]], which includes the value null,
-// on the field 'a.c'.
-assertNoMatch( { 'a.c':{ $lt:{} } } );
diff --git a/jstests/null.js b/jstests/null.js
index 4fb663ef700..f4bdeb44a4d 100644
--- a/jstests/null.js
+++ b/jstests/null.js
@@ -12,3 +12,15 @@ t.ensureIndex( { x : 1 } );
assert.eq( 1 , t.find( { x : null } ).count() , "C" );
assert.eq( 1 , t.find( { x : { $ne : null } } ).count() , "D" );
+
+// -----
+
+assert.eq( 2, t.find( { y : null } ).count(), "E" );
+
+t.ensureIndex( { y : 1 } );
+assert.eq( 2, t.find( { y : null } ).count(), "E" );
+
+t.dropIndex( { y : 1 } );
+
+t.ensureIndex( { y : 1 }, { sparse : true } );
+assert.eq( 2, t.find( { y : null } ).count(), "E" );
diff --git a/jstests/null2.js b/jstests/null2.js
new file mode 100644
index 00000000000..17b1a392714
--- /dev/null
+++ b/jstests/null2.js
@@ -0,0 +1,45 @@
+
+t = db.null2;
+t.drop();
+
+t.insert( { _id : 1, a : [ { b : 5 } ] } );
+t.insert( { _id : 2, a : [ {} ] } );
+t.insert( { _id : 3, a : [] } );
+t.insert( { _id : 4, a : [ {}, { b : 5 } ] } );
+t.insert( { _id : 5, a : [ 5, { b : 5 } ] } );
+
+function doQuery( query ) {
+ printjson( query );
+ t.find( query ).forEach(
+ function(z) {
+ print( "\t" + tojson(z) );
+ }
+ );
+ return t.find( query ).count();
+}
+
+function getIds( query ) {
+ var ids = []
+ t.find( query ).forEach(
+ function(z) {
+ ids.push( z._id );
+ }
+ );
+ return ids;
+}
+
+theQueries = [ { "a.b" : null }, { "a.b" : { $in : [ null ] } } ];
+
+for ( var i=0; i < theQueries.length; i++ ) {
+ assert.eq( 2, doQuery( theQueries[i] ) );
+ assert.eq( [2,4], getIds( theQueries[i] ) );
+}
+
+t.ensureIndex( { "a.b" : 1 } )
+
+for ( var i=0; i < theQueries.length; i++ ) {
+ assert.eq( 2, doQuery( theQueries[i] ) );
+ assert.eq( [2,4], getIds( theQueries[i] ) );
+}
+
+
diff --git a/jstests/orh.js b/jstests/orh.js
index 35f6a5b8a50..c6af92455cd 100644
--- a/jstests/orh.js
+++ b/jstests/orh.js
@@ -8,10 +8,10 @@ t.ensureIndex( {b:1,a:1} );
t.remove();
t.save( {b:2} );
-assert.eq( 0, t.count( {a:null} ) );
+assert.eq( 1, t.count( {a:null} ) );
assert.eq( 1, t.count( {b:2,a:null} ) );
assert.eq( 1, t.count( {$or:[{b:2,a:null},{a:null}]} ) );
// Is this desired?
-assert.eq( 0, t.count( {$or:[{a:null},{b:2,a:null}]} ) );
+assert.eq( 1, t.count( {$or:[{a:null},{b:2,a:null}]} ) );