[SERVER-13317] $unset should get an error on negative array indices, like $pop and $pull do Created: 22/Mar/14 Updated: 22/Mar/14 Resolved: 22/Mar/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 2.6.0-rc2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Roman Kuzmin | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
$unset should get an error on negative array indices, like $pop and $pull do Step 1.
Step 2.
Actual result: Expected result: Step 3.
|
| Comments |
| Comment by Scott Hernandez (Inactive) [ 22/Mar/14 ] |
|
As for the stats, this is byproduct of reporting after an error: |
| Comment by Roman Kuzmin [ 22/Mar/14 ] |
|
Yes, this all makes sense, thank you for the detailed answer. Actually, I simply forgot that "a.-1" may be a valid field name for another document. |
| Comment by Scott Hernandez (Inactive) [ 22/Mar/14 ] |
|
$unset is different than $pop/$pull/$pullAll in a few ways.
These all add up to the system not generating an error in this condition. Doing so now would also be a backwards breaking change with little to no value being added. If you feel like there is some significant use-case I'm overlooking please provide an example/context to discuss. |
| Comment by Roman Kuzmin [ 22/Mar/14 ] |
|
Speculation (maybe naive). $pop and $pull both return "nMatched" : 0. Perhaps they do not even try to start an operation, correctly, because the command is invalid in the first place. In contrast, $unset returns "nMatched" : 1, perhaps it does not validate the command before starting the operation though it should, too. |