[SERVER-33808] $and Query and "Implicit $and" queries are not consistent Created: 12/Mar/18 Updated: 27/Oct/23 Resolved: 12/Mar/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 3.6.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Vincenzo [X] | Assignee: | Ramon Fernandez Marina |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
I found a very strange behaviour with mongodb 3.6.3, running on Linux Centos 6.0 I always thought that those two queries:
and
were equivalent, but with the latest version (3.6.3) the results are completely different! Look at the two screenshots attached, the underlying collection is the same but the only correct result is the one with "$and" clause. In the example "births" can be a String or a Number. I ran the same query also within the mongoshell with the same inconsistent bug. Please fix it as soon as possible. |
| Comments |
| Comment by Ramon Fernandez Marina [ 12/Mar/18 ] | ||||
|
Glad to hear this one is sorted out, closing the ticket. Regards, | ||||
| Comment by Vincenzo [X] [ 12/Mar/18 ] | ||||
|
Great! You are right:
At least now I know I must focus on how I build queries with multiple conditions on the same field. | ||||
| Comment by Ramon Fernandez Marina [ 12/Mar/18 ] | ||||
|
The queries you're issuing are not of the shape {"a": 1, "b": 2}, but {"a":1, "a":2}. I'm not familiar with the program you're using to query the database, but when using the shell repeated fields are ignored, so it may be the same case in your program and what you're querying is either {"births" : {$type : 2}} or {"births": {$ne: "NA"}. Please check the program's documentation, but it's likely that
is being converted to
and that's why you need to use $and. Regards, |