[SERVER-4361] Upserts featuring $in and related operator criteria result in inconsistent behaviour depending on nesting level Created: 23/Nov/11 Updated: 07/Mar/14 Resolved: 23/Nov/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | 2.0.0, 2.0.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Remon van Vliet | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | $in, inconsistent, upsert | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
Upserts with $in clause results in either the operator being added to the document or it being ignored depending on nesting depth : > db.test.update({a:{$in:[1]}}, {$set:{v:1}}, true, false) > db.test.update({a:{b:{$in:[1]}}}, {$set:{v:1}}, true, false) }, "v" : 1 } Is this intended? And if not which one is the correct behaviour? |
| Comments |
| Comment by Remon van Vliet [ 23/Nov/11 ] | |
|
Ah, silly me. Makes sense. Thanks | |
| Comment by Scott Hernandez (Inactive) [ 23/Nov/11 ] | |
|
The first case is correct; it should be ignored. In the second case it is not the query you think it is.
It says, find me an "a" where the value is '{b:{$in:[1]}}'. Not find me an "a.b" which is 1. If you want an embedded search then you should use dot-notation. |