diff options
author | Mathias Stearn <mathias@10gen.com> | 2010-03-01 20:24:08 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2010-03-01 20:24:08 -0500 |
commit | 55df6a9a233806f3823d5fa527704a6c63e2d135 (patch) | |
tree | fc42cda231d9f0174bd799f5738a1aec254ff7b2 /db/queryutil.cpp | |
parent | bd2991edf2b80f22afe93db2d4cd7ec8493760d0 (diff) | |
download | mongo-55df6a9a233806f3823d5fa527704a6c63e2d135.tar.gz |
Fix for regex matches self with $regex object
Diffstat (limited to 'db/queryutil.cpp')
-rw-r--r-- | db/queryutil.cpp | 9 |
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) ); } } |