-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Write Ops
-
None
-
Query
Currently, if a field is referenced twice within two different modifiers, Mongo errors out, even if their is actually conflict. In other words, the error check is dumb. It's understandable why this was done, but I think this behavior deserves further consideration as Mongo matures. Take the following example:
{$set :
{age: 20}, $inc : {age: 2}}
Running this as part of an update will generate a "Field name duplication not allowed with modifiers" error. Any human reading this however can easily determine the intention, and that such an operation could have succeeded without error. The result of which should have been setting the field "age" to the value 22.
A relatively easy first step solution here, would be to allow name duplication between the $set modifiers and the other modifiers. The rule should be that the $set modifier operation should always happen first, followed by the rest of the modifiers, in order. In other words, any other modifier operations should be applied to the result of $set.
Of course I'm unaware of how easy or difficult this would be to implement in Mongo, given it's atomic nature and all, but it's worth considering whether implementing this is possible or not.
- related to
-
SERVER-10711 $setOnInsert mods should not conflict with non-insert modifiers
- Closed
-
SERVER-13578 add $setOnUpdate to update operation
- Closed
-
SERVER-28789 Add a 'initial value' parameter to $inc
- Closed
-
SERVER-6566 Support conditional updates: $updates
- Closed
-
SERVER-1050 not allowed to $push and $pop to same field in same update
- Closed