couchdb
couchdb copied to clipboard
fix(`mango`): improve handling of unsatisfiable ranges in selectors
Certain configurations of unsatisfiable field ranges could cause HTTP 500 because they are not handled, for example:
{"$and": [{"field": {"$eq": N}}, {"field": {"$gt": N}}]}
This makes mango_idx_view:end_key/1 fail because there is no clause to cover [{'$gt',35,'$eq',35}], the value that the selector becomes mapped to.
Similar field ranges are somewhat already handled by being mapped to empty so this seems to be an oversight in the original implementation. Consider the following case, which will not crash on the contrary:
{"$and": [{"field": {"$gt": N}}, {"field": {"$eq": N}}]}
Add the missing function clauses to fix this problem.
Checklist
- [x] Code is written and works correctly
- [ ] Changes are covered by tests