[SERVER-6982] positional operator does not work with negated match expressions Created: 09/Sep/12 Updated: 06/Dec/22 Resolved: 17/Jan/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Write Ops |
| Affects Version/s: | 2.4.10, 2.6.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Aaron Staple | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
The positional field name is not set when matching a negated expession (eg $ne, $nin, $not). So the $ positional operator does not work for these match expressions. Test
|
| Comments |
| Comment by Asya Kamsky [ 17/Jan/18 ] | ||||||||||||||||||
|
This issue is resolved via | ||||||||||||||||||
| Comment by Asya Kamsky [ 26/Feb/16 ] | ||||||||||||||||||
|
Shoot, it appears I may have been looking at the wrong line (I was also testing $not expressions) so you're right, the $elemMatch syntax does allow it to work. | ||||||||||||||||||
| Comment by David Storch [ 25/Feb/16 ] | ||||||||||||||||||
|
asya, I'm not sure what you mean. There's still a difference between $not/$ne inside an $elemMatch and $not/$ne without $elemMatch on 3.2.1:
Do you have an example of the case you were referring to? | ||||||||||||||||||
| Comment by Asya Kamsky [ 25/Feb/16 ] | ||||||||||||||||||
|
Both $ne and $elemMatch now (in 3.2.1) give the same error: "The positional operator did not find the match needed from the query. Unexpanded update: a.$" I think that's correct - we probably should not match on un-equality for positional match. | ||||||||||||||||||
| Comment by Asya Kamsky [ 23/Jan/14 ] | ||||||||||||||||||
|
Opened | ||||||||||||||||||
| Comment by Asya Kamsky [ 23/Jan/14 ] | ||||||||||||||||||
|
http://docs.mongodb.org/manual/reference/operator/update/positional/ However, the update does work if the negated expression is wrapped in $elemMatch: "Positional updates don't work with negated match expressions unless $elemMatch is used".
Result is array [5, 2] Tested in both 2.4.8 and 2.5.4 |