[SERVER-1356] Positional operator on update: command accepted without error, but data not updated. Created: 03/Jul/10  Updated: 08/Feb/23  Resolved: 04/Jul/10

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 1.4.4
Fix Version/s: 1.5.4

Type: Bug Priority: Major - P3
Reporter: Daniel Karp Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Operating System: Linux
Participants:

 Description   

testupdate3 did not exist at the beginning of this test.

> db.testupdate3.ensureIndex(

{'y.a':1,'y.b':1}

)
> db.testupdate3.save({x:1,y:[

{a:1,b:2}

,

{a:3,b:4}

]})

> db.testupdate3.update(

{'y.a':3,'y.b':4}

,{$set:{'y.$.b':10}},false,true)
can't append to array using string field name
> db.testupdate3.update(

{'y.a':3,'y.b':4,x:1}

,{$set:{'y.$.b':10}},false,true)
> db.testupdate2.find(

{'y.a':3,'y.b':10}

)
{ "_id" : ObjectId("4c2f5c449a684ff16748c1cf"), "x" : 1, "y" : [

{ "a" : 1, "b" : 2 }

,

{ "a" : 3, "b" : 10 }

] }
> db.testupdate3.update(

{'y.a':3,'y.b':10,x:1}

,{$set:{'y.$.b':4}},false,true)
> db.testupdate3.find()
{ "_id" : ObjectId("4c2f5d749a684ff16748c1d2"), "x" : 1, "y" : [

{ "a" : 1, "b" : 2 }

,

{ "a" : 3, "b" : 10 }

] }

Notice that the update fails, as in issue SERVER-1040, if we don't also include an additional restriction x:1 in the search.

As an additional twist, I haven't been able to make a test case for this, but in our test environment, the above sequence DID (essentially) update b back to 4 in the second update. While the data was visible if you queried on (essentially) x, if you tried to query on y.a and y.b, it did NOT find the changed records, nor did it find if it you queried on your previous values of y.

Is an index perhaps getting corrupted?



 Comments   
Comment by Eliot Horowitz (Inactive) [ 04/Jul/10 ]

This was fixed at some point in the 1.5 series

Comment by Eliot Horowitz (Inactive) [ 04/Jul/10 ]

What version are you using?
in 1.5.4 this is working for me.

Generated at Thu Feb 08 02:56:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.