[SERVER-23664] $mod match expression should raise an error when the remainder is not a number Created: 12/Apr/16 Updated: 04/Jan/22 Resolved: 08/Oct/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 4.3.1, 4.2.19 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Graeme Yeates | Assignee: | James Wahlin |
| Resolution: | Done | Votes: | 0 |
| Labels: | neweng, query-44-grooming | ||
| 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
|
||||||||||||||||
| Sprint: | Query 2019-10-21 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Other query operators treat null as NaN such as $lt, $gt, $lte, $gte $mod treats null as 0 rather than NaN and will return documents Semi related: |
| Comments |
| Comment by Githook User [ 17/Dec/21 ] | |||||||||||||
|
Author: {'name': 'Romans Kasperovics', 'email': 'romans.kasperovics@mongodb.com', 'username': 'romanskas'}Message: | |||||||||||||
| Comment by Githook User [ 08/Oct/19 ] | |||||||||||||
|
Author: {'username': 'jameswahlin', 'email': 'james.wahlin@mongodb.com', 'name': 'James Wahlin'}Message: | |||||||||||||
| Comment by David Storch [ 26/Jul/19 ] | |||||||||||||
|
This appears to be caused by a simple typo on this line: https://github.com/mongodb/mongo/blob/dc4db514a1ee737db0553f9535033453502b3ac7/src/mongo/db/matcher/expression_parser.cpp#L450 The following one-letter change causes the server to correctly raise an error when the remainder is not numeric:
I'm flagging this for re-triage. | |||||||||||||
| Comment by Ian Whalen (Inactive) [ 15/Apr/16 ] | |||||||||||||
|
this should be an error | |||||||||||||
| Comment by Kelsey Schubert [ 13/Apr/16 ] | |||||||||||||
|
Thank you for opening this ticket. I'd like to summarize the issue that you are describing. Currently, the behavior of $mod with a null remainder can be seen below:
where null is treated as 0, and documents may be returned. The expectation is that null would be treated as NaN and no documents would be returned. I am marking this ticket to be scheduled during the next round of planning. Please continue to watch for updates. Kind regards, |