diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-08-20 21:35:19 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-08-20 21:35:19 -0400 |
commit | 1bc91420b391cedbb6c7eb417735e14d202434a1 (patch) | |
tree | b92dd186d10669c35d4335ce437ef8a15abb3d14 | |
parent | 6e8e7bd75c6e8589745ab70da2deb10be5ef3698 (diff) | |
download | mongo-1bc91420b391cedbb6c7eb417735e14d202434a1.tar.gz |
fix ? case with SERVER-239
-rw-r--r-- | db/jsobj.cpp | 8 | ||||
-rw-r--r-- | jstests/regex3.js | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/db/jsobj.cpp b/db/jsobj.cpp index b872239310e..d344c19a427 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -559,7 +559,7 @@ namespace mongo { stringstream ss; for( ; *i; ++i ){ char c = *i; - if ( c == '*' ){ + if ( c == '*' || c == '?' ){ r = ss.str(); r = r.substr( 0 , r.size() - 1 ); break; @@ -1193,6 +1193,12 @@ namespace mongo { BSONObjBuilder b; b.appendRegex("r", "^f?oo"); BSONObj o = b.done(); + assert( o.firstElement().simpleRegex() == "" ); + } + { + BSONObjBuilder b; + b.appendRegex("r", "^fz?oo"); + BSONObj o = b.done(); assert( o.firstElement().simpleRegex() == "f" ); } } diff --git a/jstests/regex3.js b/jstests/regex3.js index 91ab3c5c03c..ee8d9cf5b27 100644 --- a/jstests/regex3.js +++ b/jstests/regex3.js @@ -31,7 +31,6 @@ assert.eq( 2 , t.find( { name : /^a[bc]/ } ).count() , "B i 3" ); t.drop(); t.save( { name: "" } ); -assert.eq( 1, t.count( { name: /^a?/ } ) ); -// fix -// t.ensureIndex( { name: 1 } ); -// assert.eq( 1, t.count( { name: /^a?/ } ) ); +assert.eq( 1, t.count( { name: /^a?/ } ) , "C 1" ); +t.ensureIndex( { name: 1 } ); +assert.eq( 1, t.count( { name: /^a?/ } ) , "C 2"); |