Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

arrays match themselves embedded as well SERVER-807

  • Loading branch information...
commit 2b79d806c204fe7b4782df59067921fc22202d24 1 parent d52baa2
@erh erh authored
Showing with 37 additions and 6 deletions.
  1. +5 −5 db/matcher.cpp
  2. +31 −0 jstests/array_match1.js
  3. +1 −1  jstests/nin.js
View
10 db/matcher.cpp
@@ -46,10 +46,10 @@ namespace {
}
}
-namespace mongo {
-
- //#define DEBUGMATCHER(x) cout << x << endl;
+//#define DEBUGMATCHER(x) cout << x << endl;
#define DEBUGMATCHER(x)
+
+namespace mongo {
class Where {
public:
@@ -554,7 +554,7 @@ namespace mongo {
}
return 1;
- }
+ } // end opALL
if ( compareOp == BSONObj::NE )
return matchesNe( fieldName, toMatch, obj, em , details );
@@ -672,7 +672,7 @@ namespace mongo {
}
- if ( compareOp == BSONObj::Equality && e.woCompare( toMatch ) == 0 ){
+ if ( compareOp == BSONObj::Equality && e.woCompare( toMatch , false ) == 0 ){
// match an entire array to itself
return 1;
}
View
31 jstests/array_match1.js
@@ -0,0 +1,31 @@
+
+t = db.array_match1
+t.drop();
+
+t.insert( { _id : 1 , a : [ 5 , 5 ] } )
+t.insert( { _id : 2 , a : [ 6 , 6 ] } )
+t.insert( { _id : 3 , a : [ 5 , 5 ] } )
+
+function test( f , m ){
+ var q = {};
+
+ q[f] = [5,5];
+ assert.eq( 2 , t.find( q ).itcount() , m + "1" )
+
+ q[f] = [6,6];
+ assert.eq( 1 , t.find( q ).itcount() , m + "2" )
+}
+
+test( "a" , "A" );
+t.ensureIndex( { a : 1 } )
+test( "a" , "B" );
+
+t.drop();
+
+t.insert( { _id : 1 , a : { b : [ 5 , 5 ] } } )
+t.insert( { _id : 2 , a : { b : [ 6 , 6 ] } } )
+t.insert( { _id : 3 , a : { b : [ 5 , 5 ] } } )
+
+test( "a.b" , "C" );
+t.ensureIndex( { a : 1 } )
+test( "a.b" , "D" );
View
2  jstests/nin.js
@@ -44,7 +44,7 @@ doTest = function( n ) {
checkEqual( n + " C" , "a.b" , 5 );
assert.eq( 7, t.find( { 'a.b': { $nin: [ 10 ] } } ).count() , n + " L" );
- assert.eq( 8, t.find( { 'a.b': { $nin: [ [ 10, 11 ] ] } } ).count() , n + " M" );
+ assert.eq( 7, t.find( { 'a.b': { $nin: [ [ 10, 11 ] ] } } ).count() , n + " M" );
assert.eq( 7, t.find( { a: { $nin: [ 11 ] } } ).count() , n + " N" );
t.save( { a: { b: [ 20, 30 ] } } );
Please sign in to comment.
Something went wrong with that request. Please try again.