mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-2258 specify 'undefined' for empty array index bounds
This commit is contained in:
parent
c698874735
commit
8d324fca47
@ -28,6 +28,7 @@
|
||||
|
||||
namespace mongo {
|
||||
extern BSONObj staticNull;
|
||||
extern BSONObj staticUndefined;
|
||||
|
||||
/** returns a string that when used as a matcher, would match a super set of regex()
|
||||
returns "" for complex regular expressions
|
||||
@ -165,13 +166,16 @@ namespace mongo {
|
||||
regexes.push_back( FieldRange( ie, singleKey, false, optimize ) );
|
||||
}
|
||||
else {
|
||||
// A document array may be indexed by its first element, or
|
||||
// as a full array if it is embedded within another array.
|
||||
// A document array may be indexed by its first element, by undefined
|
||||
// if it is empty, or as a full array if it is embedded within another
|
||||
// array.
|
||||
vals.insert( ie );
|
||||
if ( ie.type() == Array ) {
|
||||
if ( !ie.embeddedObject().firstElement().eoo() ) {
|
||||
vals.insert( ie.embeddedObject().firstElement() );
|
||||
}
|
||||
BSONElement temp = ie.embeddedObject().firstElement();
|
||||
if ( temp.eoo() ) {
|
||||
temp = staticUndefined.firstElement();
|
||||
}
|
||||
vals.insert( temp );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,17 +189,21 @@ namespace mongo {
|
||||
return;
|
||||
}
|
||||
|
||||
// A document array may be indexed by its first element, or
|
||||
// as a full array if it is embedded within another array.
|
||||
// A document array may be indexed by its first element, by undefined
|
||||
// if it is empty, or as a full array if it is embedded within another
|
||||
// array.
|
||||
if ( e.type() == Array && e.getGtLtOp() == BSONObj::Equality ) {
|
||||
|
||||
_intervals.push_back( FieldInterval(e) );
|
||||
const BSONElement& temp = e.embeddedObject().firstElement();
|
||||
if ( ! temp.eoo() ) {
|
||||
if ( temp < e )
|
||||
_intervals.insert( _intervals.begin() , temp );
|
||||
else
|
||||
_intervals.push_back( FieldInterval(temp) );
|
||||
BSONElement temp = e.embeddedObject().firstElement();
|
||||
if ( temp.eoo() ) {
|
||||
temp = staticUndefined.firstElement();
|
||||
}
|
||||
if ( temp < e ) {
|
||||
_intervals.insert( _intervals.begin() , temp );
|
||||
}
|
||||
else {
|
||||
_intervals.push_back( FieldInterval(temp) );
|
||||
}
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user