[SERVER-37690] countDocuments throws an error when matching 0 document Created: 20/Oct/18 Updated: 29/Oct/23 Resolved: 20/Aug/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 4.0.3, 4.1.4 |
| Fix Version/s: | 4.0.13, 4.2.1, 4.3.1 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Xavier GUIHOT | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | query-44-grooming, storch | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Minor Change | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Backport Requested: |
v4.2, v4.0
|
||||||||||||||||||||||||
| Steps To Reproduce: | ``` use count db.count.insert([\{a: 1}, \{a: 2}]) db.count.count({a:1}) // returns 1 db.count.count({a:3}) // returns 0 db.count.countDocuments({a:1}) // returns 1 db.count.countDocuments({a:3}) // throws an exception ``` |
||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
`countDocuments` throws an error when matching 0 document. I would have expected it to follow what `count` does, which is return 0. With both versions `4.0.3` and `4.1.4` (haven't checked intermediary ones), the error I get from the bellow `steps to reproduce` is:
|
| Comments |
| Comment by Githook User [ 13/Sep/19 ] |
|
Author: {'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}Message: |
| Comment by Githook User [ 13/Sep/19 ] |
|
Author: {'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}Message: |
| Comment by David Storch [ 31/Aug/19 ] |
|
jesse ravind.kumar I think we should backport this change to 4.2, since it would be nice to get this simple fix available in the most recent stable branch. I'm less sure about 4.0. I'll request backport to 4.0 and 4.2, and the query team will discuss during our next triage meeting. |
| Comment by A. Jesse Jiryu Davis [ 20/Aug/19 ] |
|
david.storch do you have an opinion about backporting? |
| Comment by Ravind Kumar (Inactive) [ 20/Aug/19 ] |
|
jesse is there any intent to backport these changes? Just curious. |
| Comment by Githook User [ 20/Aug/19 ] |
|
Author: {'username': 'ajdavis', 'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis'}Message: |
| Comment by Miha Filej [ 28/Jan/19 ] |
|
I can confirm this behaviour on 4.0.5. |