[SERVER-12680] Cannot unset from all items in array Created: 11/Feb/14 Updated: 07/Mar/14 Resolved: 11/Feb/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | James Hartig | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | See example doc in description then run: |
||||||||
| Participants: | |||||||||
| Description |
|
Running an "unset" on a key inside of array objects says it updated documents but it didn't. Example doc:
Example query:
When I run that query using the PHP driver it returns: However nothing was actually unset. I know there's another bug filed ( I said affects versions 2.2.3 because that's all we have running at Grooveshark but it might affect newer versions. |
| Comments |
| Comment by James Hartig [ 12/Feb/14 ] |
|
I understand that it might not be the right way to unset, but it should throw an error then like $set does, "can't append to array using string field name", if it is really not the right way to do it. |
| Comment by Scott Hernandez (Inactive) [ 11/Feb/14 ] |
|
Yes, that issue is the one to track and the syntax you are using does not do what you want, it will just unset an embedded field, not array elements. |
| Comment by James Hartig [ 11/Feb/14 ] |
|
You can actually workaround this if you know all of the indexes by specifying each index separately: But if your array is unbounded (as most are?) then you cannot do this. |