Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix pull with primitives and $ops SERVER-1697

  • Loading branch information...
commit 0d8b5981ff7a3df062cfa5839e292718b61911c2 1 parent f8da5e0
@erh erh authored
Showing with 16 additions and 3 deletions.
  1. +3 −0  db/update.cpp
  2. +12 −2 db/update.h
  3. +1 −1  jstests/pull_remove1.js
View
3  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
View
14 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 ){
View
2  jstests/pull_remove1.js
@@ -10,5 +10,5 @@ assert.eq( o , t.findOne() , "A1" )
o.a = o.a.filter( function(z){ return z >= 6; } )
t.update( {} , { $pull : { a : { $lt : 6 } } } )
-//assert.eq( o.a , t.findOne().a , "A2" )
+assert.eq( o.a , t.findOne().a , "A2" )
Please sign in to comment.
Something went wrong with that request. Please try again.