[CSHARP-2353] BsonDocument.DeepClone() fails on documents with duplicate element names Created: 09/Aug/18 Updated: 31/Mar/22 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.7.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Adam Milazzo | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Backwards Compatibility: | Minor Change |
| Description |
|
The following code fails: var doc = new BsonDocument() { AllowDuplicateNames = true }; doc.Add("a", 1); doc.Add("a", 2); var doc2 = doc.DeepClone();
This is because DeepClone does: {{ BsonDocument clone = new BsonDocument();}} Changing the first line to: BsonDocument clone = new BsonDocument() { AllowDuplicateNames = AllowDuplicateNames }; fixes the problem.
|
| Comments |
| Comment by Adam Milazzo [ 09/Aug/18 ] |
|
Created pull request: https://github.com/mongodb/mongo-csharp-driver/pull/338 |