summaryrefslogtreecommitdiff
path: root/db/queryutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'db/queryutil.cpp')
-rw-r--r--db/queryutil.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/db/queryutil.cpp b/db/queryutil.cpp
index 52551588096..2d0496be20d 100644
--- a/db/queryutil.cpp
+++ b/db/queryutil.cpp
@@ -177,9 +177,16 @@ namespace mongo {
upperInclusive = false; //MaxForType String is an empty Object
}
+ // regex matches self
if (e.type() == RegEx){
BSONElement re = addObj( BSON( "" << e ) ).firstElement();
- intervals_.push_back( FieldInterval(re) ); // regex matches self
+ intervals_.push_back( FieldInterval(re) );
+ } else {
+ BSONObj orig = e.embeddedObject();
+ BSONObjBuilder b;
+ b.appendRegex("", orig["$regex"].valuestrsafe(), orig["$options"].valuestrsafe());
+ BSONElement re = addObj( b.obj() ).firstElement();
+ intervals_.push_back( FieldInterval(re) );
}
}