[SERVER-9116] $pull operation does not work with $each Created: 25/Mar/13 Updated: 10/Dec/14 Resolved: 25/Mar/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 2.4.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Anatoly Borisov | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | Copy-paste from console: > db.test.save({_id : 1}) > db.test.update({_id : 1}, {$addToSet: {flags : {$each : [1,2,3,4,5,6]}}}) > db.test.update({_id : 1}, {$pull: {flags : {$each : [1,2,3]}}}) |
||||||||
| Participants: | |||||||||
| Description |
|
$addToSet with $each works OK, but $pull does not |
| Comments |
| Comment by Anatoly Borisov [ 25/Mar/13 ] |
|
Then it should raise a syntax error or something, I guess |
| Comment by Scott Hernandez (Inactive) [ 25/Mar/13 ] |
|
This is not a bug, and is expected behavior. The push syntax is different than the pull syntax because the latter is a query. $pull takes a query so there is no need for it to take a $each + array. There is a $pullAll if you want but that is just for scalars (not a query). It is just a convienience methods at this point since you can craft an $in/$or query using $pull. In your example you can use $in to replace $each and it will work as you want. |