[SERVER-5565] Handle negative array offsets consistently Created: 10/Apr/12 Updated: 10/Dec/14 Resolved: 05/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Richard Kreuter (Inactive) | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
update, find, and $slice don't agree about what negative integers mean: $slice treats negatives as offsets from the right end of the array, find doesn't (seem to) support them at all, and update does something weird:
I didn't check what aggregation framework operators do... |
| Comments |
| Comment by Scott Hernandez (Inactive) [ 05/Dec/13 ] | |||||||||||||
|
I checked with query and aggregation and things now seem consistent. Please reopen if you find more things. | |||||||||||||
| Comment by Scott Hernandez (Inactive) [ 05/Dec/13 ] | |||||||||||||
|
Kurt, you can now, when 2.6 stable is out, use $position to specify the position to push into an array with, so this is probably what you want.
Richard, this is no longer supported in updates (albeit with a less than optimal error message):
| |||||||||||||
| Comment by Kurt Agius [ 11/Feb/13 ] | |||||||||||||
|
The update -1 is a requirement which i think is quiet common. So we need to update the last item in the array, which is expected to be: db.a.update({}, { $set : { "x.-1" : 1 }} ); Any idea if this is planned to be supported very soon ? |