Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix array matching in matcher only SERVER-161

  • Loading branch information...
commit 84e996ca2857bca34b8993f271e18c1e34fcf5cf 1 parent 443c401
@erh erh authored
Showing with 26 additions and 8 deletions.
  1. +2 −0  db/matcher.cpp
  2. +14 −0 jstests/array1.js
  3. +10 −8 jstests/multi.js
View
2  db/matcher.cpp
@@ -430,6 +430,8 @@ namespace mongo {
return 1;
}
}
+ if ( compareOp == BSONObj::Equality && e.woCompare( toMatch ) == 0 )
+ return 1;
}
else if ( e.eoo() ) {
// 0 indicates "missing element"
View
14 jstests/array1.js
@@ -0,0 +1,14 @@
+t = db.array1
+t.drop()
+
+x = { a : [ 1 , 2 ] };
+
+t.save( { a : [ [1,2] ] } );
+assert.eq( 1 , t.find( x ).count() , "A" );
+
+t.save( x );
+delete x._id;
+assert.eq( 2 , t.find( x ).count() , "B" );
+
+t.ensureIndex( { a : 1 } );
+//assert.eq( 2 , t.find( x ).count() , "C" ); // TODO turn this on
View
18 jstests/multi.js
@@ -3,20 +3,22 @@ t.drop();
t.ensureIndex( { a: 1 } );
t.save( { a: [ 1, 2 ] } );
-assert.eq( 1, t.find( { a: { $gt: 0 } } ).count() );
-assert.eq( 1, t.find( { a: { $gt: 0 } } ).toArray().length );
+assert.eq( 1, t.find( { a: { $gt: 0 } } ).count() , "A" );
+assert.eq( 1, t.find( { a: { $gt: 0 } } ).toArray().length , "B" );
t.drop();
t.save( { a: [ [ [ 1 ] ] ] } );
-assert.eq( 0, t.find( { a:1 } ).count() );
-assert.eq( 0, t.find( { a: [ 1 ] } ).count() );
-assert.eq( 1, t.find( { a: [ [ 1 ] ] } ).count() );
-assert.eq( 0, t.find( { a: [ [ [ 1 ] ] ] } ).count() );
+assert.eq( 0, t.find( { a:1 } ).count() , "C" );
+assert.eq( 0, t.find( { a: [ 1 ] } ).count() , "D" );
+assert.eq( 1, t.find( { a: [ [ 1 ] ] } ).count() , "E" );
+assert.eq( 1, t.find( { a: [ [ [ 1 ] ] ] } ).count() , "F" );
t.drop();
t.save( { a: [ 1, 2 ] } );
-assert.eq( 0, t.find( { a: { $ne: 1 } } ).count() );
+assert.eq( 0, t.find( { a: { $ne: 1 } } ).count() , "G" );
t.drop();
t.save( { a: [ { b: 1 }, { b: 2 } ] } );
-assert.eq( 0, t.find( { 'a.b': { $ne: 1 } } ).count() );
+assert.eq( 0, t.find( { 'a.b': { $ne: 1 } } ).count() , "H" );
+
+// TODO - run same tests with an index on a
Please sign in to comment.
Something went wrong with that request. Please try again.