[SERVER-42018] $expr operators are not implicitly ANDed in compound queries Created: 30/Jun/19 Updated: 20/Aug/20 Resolved: 16/Jul/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dan Dascalescu | Assignee: | Eric Sedor |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | If I move both $expr condition into one $expr with an explicit $and, the query performs correctly, I don't understand why the implicit AND doesn't work in this case. |
||||||||
| Participants: | |||||||||
| Description |
|
The documentation for queries states that,
Therefore, I expect this query with two $expr fields to find documents with an array where field foo is the same at indexes 0 and 1, and field bar is different:
What happens is that other documents are returned as well, where foo is different between arrO[0] and arrO[1]. Collection:
|
| Comments |
| Comment by Eric Sedor [ 16/Jul/19 ] |
|
I am going to close this ticket as a duplicate of SERVER-6439. You can watch that ticket for updates on this behavior. Thanks again! |
| Comment by Eric Sedor [ 03/Jul/19 ] |
|
dandv, actually--independent of version--this is likely due to the duplicate $expr fields at the same level of the query document. SERVER-6439 is open about this but in short, an explicit $and is required when specifying statements like this. |
| Comment by Eric Sedor [ 02/Jul/19 ] |
|
Hi dandv; thanks for your report so far. Can you please clarify what version you are seeing this on? |