Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use .$ instead of .~ for SERVER-631

  • Loading branch information...
commit bca88a8001e471b85af0787a39300d3ae2fa29f8 1 parent 93c286d
@erh erh authored
View
6 db/update.cpp
@@ -621,7 +621,7 @@ namespace mongo {
uassert( 10152 , "Modifier $inc allowed for numbers only", f.isNumber() || op != Mod::INC );
uassert( 10153 , "Modifier $pushAll/pullAll allowed for arrays only", f.type() == Array || ( op != Mod::PUSH_ALL && op != Mod::PULL_ALL ) );
- _hasDynamicArray = _hasDynamicArray || strstr( fieldName , "~" ) > 0;
+ _hasDynamicArray = _hasDynamicArray || strstr( fieldName , ".$" ) > 0;
Mod m;
m.init( op , f );
@@ -646,13 +646,13 @@ namespace mongo {
n->_hasDynamicArray = _hasDynamicArray;
for ( ModHolder::const_iterator i=_mods.begin(); i!=_mods.end(); i++ ){
string s = i->first;
- size_t idx = s.find( "~" );
+ size_t idx = s.find( ".$" );
if ( idx == string::npos ){
n->_mods[s] = i->second;
continue;
}
StringBuilder buf(s.size()+strlen(elemMatchKey));
- buf << s.substr(0,idx) << elemMatchKey << s.substr(idx+1);
+ buf << s.substr(0,idx+1) << elemMatchKey << s.substr(idx+2);
string fixed = buf.str();
DEBUGUPDATE( "fixed dynamic: " << s << " -->> " << fixed );
n->_mods[fixed] = i->second;
View
2  jstests/update_arraymatch1.js
@@ -11,6 +11,6 @@ t.update( q , { $set : { b : 5 } } )
o.b = 5
assert.eq( o , t.findOne() , "A2" )
-t.update( { "a.x" : 2 } , { $inc : { "a.~.y" : 1 } } )
+t.update( { "a.x" : 2 } , { $inc : { "a.$.y" : 1 } } )
o.a[1].y++;
assert.eq( o , t.findOne() , "A3" );
View
6 jstests/update_arraymatch2.js
@@ -4,14 +4,14 @@ t.drop();
t.insert( { } );
t.insert( { x : [1,2,3] } );
t.insert( { x : 99 } );
-t.update( {x : 2}, { $inc : { "x.~" : 1 } } , false, true );
+t.update( {x : 2}, { $inc : { "x.$" : 1 } } , false, true );
assert( t.findOne({x:1}).x[1] == 3, "A1" );
t.insert( { x : { y : [8,7,6] } } )
-t.update( {'x.y' : 7}, { $inc : { "x.y.~" : 1 } } , false, true )
+t.update( {'x.y' : 7}, { $inc : { "x.y.$" : 1 } } , false, true )
//printjson( t.findOne({"x.y" : 8}) );
assert.eq( 8 , t.findOne({"x.y" : 8}).x.y[1] , "B1" );
t.insert( { x : [90,91,92], y : ['a', 'b', 'c'] } );
-t.update( { x : 92} , { $set : { 'y.~' : 'z' } }, false, true );
+t.update( { x : 92} , { $set : { 'y.$' : 'z' } }, false, true );
assert.eq( 'z', t.findOne({x:92}).y[2], "B2" );
Please sign in to comment.
Something went wrong with that request. Please try again.