2010-04-27 06:24:12 +02:00
|
|
|
|
|
|
|
t = db.update_arraymatch4
|
|
|
|
t.drop()
|
|
|
|
|
2010-05-10 20:38:10 +02:00
|
|
|
x = { _id : 1 , arr : ["A1","B1","C1"] }
|
2010-04-27 06:24:12 +02:00
|
|
|
t.insert( x )
|
|
|
|
assert.eq( x , t.findOne() , "A1" )
|
|
|
|
|
2010-05-10 20:38:10 +02:00
|
|
|
x.arr[0] = "A2"
|
|
|
|
t.update( { arr : "A1" } , { $set : { "arr.$" : "A2" } } )
|
2010-04-27 06:24:12 +02:00
|
|
|
assert.eq( x , t.findOne() , "A2" )
|
|
|
|
|
2010-05-10 20:38:10 +02:00
|
|
|
t.ensureIndex( { arr : 1 } )
|
|
|
|
x.arr[0] = "A3"
|
|
|
|
t.update( { arr : "A2" } , { $set : { "arr.$" : "A3" } } )
|
|
|
|
assert.eq( x , t.findOne() , "A3" ); // SERVER-1055
|
2010-04-27 06:24:12 +02:00
|
|
|
|
|
|
|
|