summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-09-24 15:40:59 -0400
committerEliot Horowitz <eliot@10gen.com>2010-09-24 15:40:59 -0400
commit0d8b5981ff7a3df062cfa5839e292718b61911c2 (patch)
tree76e8051d2522eac10f5b480035a61b89e0b02849 /db
parentf8da5e06860a0d5e0fd7b5637fcc748127cfbcc3 (diff)
downloadmongo-0d8b5981ff7a3df062cfa5839e292718b61911c2.tar.gz
fix pull with primitives and $ops SERVER-1697
Diffstat (limited to 'db')
-rw-r--r--db/update.cpp3
-rw-r--r--db/update.h14
2 files changed, 15 insertions, 2 deletions
diff --git a/db/update.cpp b/db/update.cpp
index 7891b329048..a59387d860e 100644
--- a/db/update.cpp
+++ b/db/update.cpp
@@ -40,6 +40,9 @@ namespace mongo {
// if elt isn't an object, then comparison will work
return toMatch.woCompare( elt , false ) == 0;
}
+
+ if ( matcherOnPrimitive )
+ return matcher->matches( toMatch.wrap( "" ) );
if ( toMatch.type() != Object ){
// looking for an object, so this can't match
diff --git a/db/update.h b/db/update.h
index b7950de7306..eeec3d2460d 100644
--- a/db/update.h
+++ b/db/update.h
@@ -43,12 +43,22 @@ namespace mongo {
BSONElement elt; // x:5 note: this is the actual element from the updateobj
boost::shared_ptr<Matcher> matcher;
+ bool matcherOnPrimitive;
void init( Op o , BSONElement& e ){
op = o;
elt = e;
- if ( op == PULL && e.type() == Object )
- matcher.reset( new Matcher( e.embeddedObject() ) );
+ if ( op == PULL && e.type() == Object ){
+ BSONObj t = e.embeddedObject();
+ if ( t.firstElement().getGtLtOp() == 0 ){
+ matcher.reset( new Matcher( t ) );
+ matcherOnPrimitive = false;
+ }
+ else {
+ matcher.reset( new Matcher( BSON( "" << t ) ) );
+ matcherOnPrimitive = true;
+ }
+ }
}
void setFieldName( const char * s ){