mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
sm regex -> bson
This commit is contained in:
parent
a27d79d7a7
commit
60f76f524f
@ -260,9 +260,9 @@ namespace JSTests {
|
||||
|
||||
s->invoke( "z = { a : x.r };" , BSONObj() );
|
||||
|
||||
//BSONObj out = s->getObject("z");
|
||||
//ASSERT_EQUALS( (string)"^a" , out["a"].regex() );
|
||||
//ASSERT_EQUALS( (string)"i" , out["a"].regexFlags() );
|
||||
BSONObj out = s->getObject("z");
|
||||
ASSERT_EQUALS( (string)"^a" , out["a"].regex() );
|
||||
ASSERT_EQUALS( (string)"i" , out["a"].regexFlags() );
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,18 @@ namespace mongo {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSTYPE_FUNCTION: b.appendCode( name.c_str() , getFunctionCode( val ).c_str() ); break;
|
||||
case JSTYPE_FUNCTION: {
|
||||
string s = toString(val);
|
||||
if ( s[0] == '/' ){
|
||||
s = s.substr(1);
|
||||
string::size_type end = s.rfind( '/' );
|
||||
b.appendRegex( name.c_str() , s.substr( 0 , end ).c_str() , s.substr( end + 1 ).c_str() );
|
||||
}
|
||||
else {
|
||||
b.appendCode( name.c_str() , getFunctionCode( val ).c_str() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: uassert( (string)"can't append field. name:" + name + " type: " + typeString( val ) , 0 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user