[CSHARP-1976] UpdateDefinitionBuilder generates incorrect Bson when using $set and multiple array subdocs Created: 03/May/17  Updated: 07/Feb/22  Resolved: 07/Feb/22

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.4.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Greg Lincoln Assignee: Unassigned
Resolution: Done Votes: 0
Labels: triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: CSHARP-3615

 Description   

Given the following simple documents and UpdateDefinition:

class Thing
{
    public int Value { get; set; }
    public IList<SubThing> SubThings { get; set; }
}
 
class SubThing
{
    public int SubValue { get; set; }
}
var ud = new UpdateDefinitionBuilder<Thing>().Set(o => o.Value, 1)
                .Set(o => o.SubThings[0].SubValue, 0)
                .Set(o => o.SubThings[1].SubValue, 1);

I get the following incorrect BSON:
{ "$set" :

{ "Value" : 1, "SubThings.2.SubValue" : 1 }

}

I'm expecting:
{ "$set" : { "Value" : 1, "SubThings.0.SubValue" : 0, "SubThings.1.SubValue" : 1 }}

This only seems to occur when using a lambda field selector.



 Comments   
Comment by James Kovacs [ 07/Feb/22 ]

This works correctly on recent version of the driver at least as far back as 2.9.0. Please re-open this issue with additional details if it still does not work as expected with your use case.

Generated at Wed Feb 07 21:41:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.