summaryrefslogtreecommitdiff
path: root/db/queryutil.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-03-01 20:24:08 -0500
committerMathias Stearn <mathias@10gen.com>2010-03-01 20:24:08 -0500
commit55df6a9a233806f3823d5fa527704a6c63e2d135 (patch)
treefc42cda231d9f0174bd799f5738a1aec254ff7b2 /db/queryutil.cpp
parentbd2991edf2b80f22afe93db2d4cd7ec8493760d0 (diff)
downloadmongo-55df6a9a233806f3823d5fa527704a6c63e2d135.tar.gz
Fix for regex matches self with $regex object
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) );
}
}