[CSHARP-902] UpdateBuilder.Set should overwrite value if called twice with the same field Created: 24/Jan/14 Updated: 20/Mar/14 Resolved: 24/Jan/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Amith George | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Refer StackOverflow question (http://stackoverflow.com/q/21227428/30007) for detailed description. The answer to that question also suggests a workaround in the meanwhile. var update = new UpdateBuilder<SomeClass>(); |
| Comments |
| Comment by Robert Stam [ 24/Jan/14 ] |
|
See original ticket |
| Comment by Robert Stam [ 24/Jan/14 ] |
|
This ticket is a duplicate. Linking to the original ticket and resolving this one. |
| Comment by Robert Stam [ 24/Jan/14 ] |
|
The server only allows one update operator per field. The current implementation of the Update builder makes no attempt to enforce this (perhaps it should?). If you apply multiple different update operators to the same field you will get an error server side. If you apply the same update operator (in your case Set) to the same field you get an exception client side, as a side effect of BsonDocument not allowing duplicate element names. So the options here are: 1. Allow Set to be called multiple times (and last one wins) Either way, whatever solution is adopted should be generalized to all update operators, not just Set. |