Permalink
Browse files

SERVER-322 $nin and regex

  • Loading branch information...
1 parent 916468b commit 6c7dc2b0f8831fac6621f125889d873241588b02 @astaple astaple committed Mar 9, 2010
Showing with 24 additions and 9 deletions.
  1. +11 −0 db/matcher.cpp
  2. +13 −9 jstests/regex5.js
View
@@ -565,6 +565,17 @@ namespace mongo {
if ( ret != 1 )
return ret;
}
+ if ( em.myregex.get() ) {
+ BSONElementSet s;
+ obj.getFieldsDotted( fieldName, s );
+ for( vector<RegexMatcher>::const_iterator i = em.myregex->begin(); i != em.myregex->end(); ++i ) {
+ for( BSONElementSet::const_iterator j = s.begin(); j != s.end(); ++j ) {
+ if ( regexMatches( *i, *j ) ) {
+ return -1;
+ }
+ }
+ }
+ }
return 1;
}
View
@@ -10,15 +10,19 @@ x = /.*y.*/
doit = function() {
-assert.eq( 1 , t.find( { x : a } ).count() , "A" )
-assert.eq( 2 , t.find( { x : x } ).count() , "B" )
-assert.eq( 2 , t.find( { x : { $in: [ x ] } } ).count() , "C" ) // SERVER-322
-assert.eq( 1 , t.find( { x : { $in: [ a, "xyz1" ] } } ).count() , "D" ) // SERVER-322
-assert.eq( 2 , t.find( { x : { $in: [ a, "xyz2" ] } } ).count() , "E" ) // SERVER-322
-assert.eq( 1 , t.find( { x : { $all : [ a , x ] } } ).count() , "F" ) // SERVER-505
-assert.eq( 1 , t.find( { x : { $all : [ a , "abc" ] } } ).count() , "G" ) // SERVER-505
-assert.eq( 0 , t.find( { x : { $all : [ a , "ac" ] } } ).count() , "H" ) // SERVER-505
-
+ assert.eq( 1 , t.find( { x : a } ).count() , "A" );
+ assert.eq( 2 , t.find( { x : x } ).count() , "B" );
+ assert.eq( 2 , t.find( { x : { $in: [ x ] } } ).count() , "C" ); // SERVER-322
+ assert.eq( 1 , t.find( { x : { $in: [ a, "xyz1" ] } } ).count() , "D" ); // SERVER-322
+ assert.eq( 2 , t.find( { x : { $in: [ a, "xyz2" ] } } ).count() , "E" ); // SERVER-322
+ assert.eq( 1 , t.find( { x : { $all : [ a , x ] } } ).count() , "F" ); // SERVER-505
+ assert.eq( 1 , t.find( { x : { $all : [ a , "abc" ] } } ).count() , "G" ); // SERVER-505
+ assert.eq( 0 , t.find( { x : { $all : [ a , "ac" ] } } ).count() , "H" ); // SERVER-505
+ assert.eq( 0 , t.find( { x : { $nin: [ x ] } } ).count() , "I" ); // SERVER-322
+ assert.eq( 1 , t.find( { x : { $nin: [ a, "xyz1" ] } } ).count() , "J" ); // SERVER-322
+ assert.eq( 0 , t.find( { x : { $nin: [ a, "xyz2" ] } } ).count() , "K" ); // SERVER-322
+ assert.eq( 2 , t.find( { x : { $not: { $nin: [ x ] } } } ).count() , "L" ); // SERVER-322
+ assert.eq( 1 , t.find( { x : { $nin: [ /^a.c/ ] } } ).count() , "M" ) // SERVER-322
}
doit();

0 comments on commit 6c7dc2b

Please sign in to comment.