mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
SERVER-251 /regex checkpoint
This commit is contained in:
parent
0ce8996a44
commit
fe607048a1
@ -246,7 +246,7 @@ namespace mongo {
|
||||
addRegex( fe, e.fieldName(), true );
|
||||
continue;
|
||||
default:
|
||||
assert( false );
|
||||
uassert( 13024, "invalid use of $not", false );
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,10 +307,12 @@ namespace mongo {
|
||||
break;
|
||||
}
|
||||
case BSONObj::opREGEX:{
|
||||
uassert( 13022, "can't use $not with $regex, use BSON regex type instead", !isNot );
|
||||
regex = fe.valuestrsafe();
|
||||
break;
|
||||
}
|
||||
case BSONObj::opOPTIONS:{
|
||||
uassert( 13023, "can't use $not with $options, use BSON regex type instead", !isNot );
|
||||
flags = fe.valuestrsafe();
|
||||
break;
|
||||
}
|
||||
@ -626,7 +628,7 @@ namespace mongo {
|
||||
if ( cmp == 0 ) {
|
||||
/* missing is ok iff we were looking for null */
|
||||
if ( m.type() == jstNULL || m.type() == Undefined ) {
|
||||
if ( bm.compareOp == BSONObj::NE ^ bm.isNot ) {
|
||||
if ( ( bm.compareOp == BSONObj::NE ) ^ bm.isNot ) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -11,10 +11,15 @@ check = function( query, expected, size ) {
|
||||
}
|
||||
}
|
||||
|
||||
fail = function( query ) {
|
||||
t.count( query );
|
||||
assert( db.getLastError(), tojson( query ) );
|
||||
}
|
||||
|
||||
t.save( {i:"a"} );
|
||||
t.save( {i:"b"} );
|
||||
|
||||
//check( {i:{$not:"a"}}, "b" );
|
||||
fail( {i:{$not:"a"}} );
|
||||
check( {i:{$not:{$gt:"a"}}}, "a" );
|
||||
check( {i:{$not:{$gte:"b"}}}, "a" );
|
||||
check( {i:{$exists:true}}, "a", 2 );
|
||||
@ -28,9 +33,17 @@ check( {i:{$not:{$nin:["a"]}}}, "a" );
|
||||
// $mod
|
||||
// $size
|
||||
check( {i:{$not:/a/}}, "b" );
|
||||
check( {i:{$not:/a/,$regex:"b"}}, "b" );
|
||||
check( {i:{$not:/(a|b)/}}, "", 0 );
|
||||
check( {i:{$not:/a/,$regex:"a"}}, "", 0 );
|
||||
check( {i:{$not:/aa/}}, "a", 2 );
|
||||
// other type of regex
|
||||
fail( {i:{$not:{$regex:"a"}}} );
|
||||
fail( {i:{$not:{$options:"a"}}} );
|
||||
|
||||
t.drop();
|
||||
t.save( {i:1} );
|
||||
check( {i:{$not:{$mod:[5,1]}}}, null, 0 );
|
||||
check( {i:{$mod:[5,2]}}, null, 0 );
|
||||
check( {i:{$not:{$mod:[5,2]}}}, 1, 1 );
|
||||
|
||||
//in array
|
||||
//$all
|
||||
|
Loading…
Reference in New Issue
Block a user