[SERVER-16343] $pull using DBRef $id and $in operator Created: 27/Nov/14 Updated: 28/Nov/14 Resolved: 28/Nov/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Gabriel Brieva | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Steps To Reproduce: | I have this two documents: { , { $ref : "bar", $id : ObjectId("54480b5f18c7885d7651a140") } ] { , { $ref : "bar", $id : ObjectId("54773af88328753e92484be8") } ] When I use $pull to remove some of DBRef entries and using $in too, none of them are removed. This is the query: db.test.update({}, {$pull: } |
| Participants: |
| Description |
|
When I use $pull to remove some DBRef using $id and $in operator, none of them are remove. If the $id field have another name works. |
| Comments |
| Comment by Asya Kamsky [ 28/Nov/14 ] | |
|
That case should not work - I believe that may be a bug. I will check why this case works contrary to documentation. | |
| Comment by Gabriel Brieva [ 28/Nov/14 ] | |
|
But in this case works: Two documents: { "foo" : "test1", "rel" : [ { "t" : "t", "id" : 2 }, { "t" : "t", "id" : 3 }] } { "foo" : "test2", "rel" : [ { "t" : "t", "id" : 2 }, { "t" : "t", "id" : 1 }] } The query: db.test.update({}, {"$pull": { "rel": { "id": { "$in": [1, 3] }} } }, {"multi": true}) That query remove {"t" : "t", "id" : 1}and {"t" : "t", "id" : 3}from documents. So, why don't works for DBRef case? | |
| Comment by Asya Kamsky [ 28/Nov/14 ] | |
|
The result you're getting is correct. Documentation for $pull specifies a number of behaviors: Note it says: You are asking to pull by trying to match document where "rel" has the value {"$id": ...} which is not the object that "rel" has. What will work is:
|