[SERVER-23262] Using a $elemMatch with two $eq queries returns incorrect results Created: 21/Mar/16 Updated: 23/Mar/16 Resolved: 23/Mar/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 3.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jason Mccullough | Assignee: | Kelsey Schubert |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows Server 2008R2, MongoChef |
||
| Operating System: | ALL | ||||
| Steps To Reproduce: | doc:
Queries:
Both queries return two documents. even though 2nd query specifies a values that does NOT exist in any document. Replacing the $elemMath by a $and does not exhibit the same behaviour and returns the correct results. |
||||
| Participants: |
| Description |
|
Using a $elemMatch with two $eq queries is returning all documents that only one of the $eq. And which one is matched depends on the order of the $eq in the statement. |
| Comments |
| Comment by Kelsey Schubert [ 23/Mar/16 ] | ||
|
Thank you for the report. This is expected behavior, and is a result of how javascript objects/dicts work:
You cannot have repeated fields of the same name at the same level. My understanding is that you have identified that a query using the $and operator fulfills the needs of your use case. Kind regards, | ||
| Comment by Jason Mccullough [ 21/Mar/16 ] | ||
|
Explain gives: } clearly considering only one eq... |