[CSHARP-415] BsonDocument.ToDictionary converts an array of nested documents/arrays to an array of null values Created: 24/Mar/12 Updated: 02/Apr/15 Resolved: 10/Apr/12 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.3.1 |
| Fix Version/s: | 1.4.1 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Daniel Goldman | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
If a BsonDocument contains an array of nested documents or nested arrays, calling BsonDocument.ToDictionary will convert all of the array values to null. It looks like this occurs because BsonArray.CopyTo calls each of its elements' RawValue methods, which return null for BsonDocument and BsonArray instances. I've attached a CS file with new ToDictionary and helper methods that fix this error. At the bottom of the file is the test case I used to reproduce and then correct it. |
| Comments |
| Comment by Robert Stam [ 10/Apr/12 ] |
|
When mapping from .NET data types to BsonDocument object model null is mapped to BsonNull.Value. When creating BsonValues using functional construction null is ignored. |