[SERVER-7264] numeric mod prevents application of positional mod on same field, without uassert Created: 04/Oct/12  Updated: 11/Jul/16  Resolved: 27/Jul/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.5.2

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

If an explicit array field mod and a positional mod reference the same field, the numeric mod currently wins out. Generally when (non positional) mods may conflict we uassert instead of allowing one to trump the other. We might consider adopting a policy that is similar to that.

Test:

c = db.c;
c.drop();
 
c.save( { a:[ 1 ] } );
// The 'a.0' update wins out here:
c.update( { a:1 }, { $set:{ 'a.0':2, 'a.$':3 } } );
printjson( c.find().toArray() );



 Comments   
Comment by Scott Hernandez (Inactive) [ 27/Jul/13 ]

Fixed in SERVER-7175.

In the new update code this fails:

>c.drop()
true
> c.find()
> c.save( { a:[ 1 ] } );
> c.update( { a:1 }, { $set:{ 'a.0':2, 'a.$':3 } } );
Cannot update 'a.0' and 'a.0' at the same time

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