mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
JSON parser supports 'new Date(1234)' SERVER-461
This commit is contained in:
parent
b04c8cfe25
commit
692b618d7d
@ -509,7 +509,7 @@ public:
|
||||
// TODO: this will need to use a signed parser at some point
|
||||
date = dateS | dateT;
|
||||
dateS = ch_p( '{' ) >> "\"$date\"" >> ':' >> uint_parser< Date_t >()[ dateValue( self.b ) ] >> '}';
|
||||
dateT = str_p( "Date" ) >> '(' >> uint_parser< Date_t >()[ dateValue( self.b ) ] >> ')';
|
||||
dateT = !str_p("new") >> str_p( "Date" ) >> '(' >> uint_parser< Date_t >()[ dateValue( self.b ) ] >> ')';
|
||||
|
||||
regex = regexS | regexT;
|
||||
regexS = ch_p( '{' ) >> "\"$regex\"" >> ':' >> str[ regexValue( self.b ) ] >> ',' >> "\"$options\"" >> ':' >> lexeme_d[ '"' >> ( *( alpha_p ) )[ regexOptions( self.b ) ] >> '"' ] >> '}';
|
||||
|
@ -950,7 +950,7 @@ namespace JsonTests {
|
||||
}
|
||||
};
|
||||
|
||||
class EmbeddedDates : public Base {
|
||||
class EmbeddedDatesBase : public Base {
|
||||
public:
|
||||
|
||||
virtual void run(){
|
||||
@ -971,11 +971,24 @@ namespace JsonTests {
|
||||
b.append( "time.valid" , e.obj() );
|
||||
return b.obj();
|
||||
}
|
||||
virtual string json() const = 0;
|
||||
};
|
||||
|
||||
struct EmbeddedDatesFormat1 : EmbeddedDatesBase {
|
||||
string json() const {
|
||||
return "{ \"time.valid\" : { $gt : { \"$date\" : 1257829200000 } , $lt : { \"$date\" : 1257829200100 } } }";
|
||||
}
|
||||
};
|
||||
struct EmbeddedDatesFormat2 : EmbeddedDatesBase {
|
||||
string json() const {
|
||||
return "{ \"time.valid\" : { $gt : Date(1257829200000) , $lt : Date( 1257829200100 ) } }";
|
||||
}
|
||||
};
|
||||
struct EmbeddedDatesFormat3 : EmbeddedDatesBase {
|
||||
string json() const {
|
||||
return "{ \"time.valid\" : { $gt : new Date(1257829200000) , $lt : new Date( 1257829200100 ) } }";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace FromJsonTests
|
||||
@ -1058,7 +1071,9 @@ namespace JsonTests {
|
||||
add< FromJsonTests::ObjectId2 >();
|
||||
add< FromJsonTests::NumericTypes >();
|
||||
add< FromJsonTests::NegativeNumericTypes >();
|
||||
add< FromJsonTests::EmbeddedDates >();
|
||||
add< FromJsonTests::EmbeddedDatesFormat1 >();
|
||||
add< FromJsonTests::EmbeddedDatesFormat2 >();
|
||||
add< FromJsonTests::EmbeddedDatesFormat3 >();
|
||||
}
|
||||
} myall;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user