interval: the IN operator can now check if an integer value is inlcuded in a range
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.portale-stac.it/go-pkg/expr/sym"
|
||||
"git.portale-stac.it/go-pkg/expr/types/array"
|
||||
"git.portale-stac.it/go-pkg/expr/types/dict"
|
||||
"git.portale-stac.it/go-pkg/expr/types/interval"
|
||||
"git.portale-stac.it/go-pkg/expr/types/list"
|
||||
)
|
||||
|
||||
@@ -46,6 +47,9 @@ func evalIn(ctx kern.ExprContext, opTerm *scan.Term) (v any, err error) {
|
||||
} else if list.IsLinkedList(rightValue) {
|
||||
ls, _ := rightValue.(*list.LinkedList)
|
||||
v = ls.HasValue(leftValue)
|
||||
} else if interval.IsInterval(rightValue) {
|
||||
r, _ := rightValue.(*interval.IntervalType)
|
||||
v = r.Contains(leftValue)
|
||||
} else {
|
||||
err = opTerm.ErrIncompatibleTypes(leftValue, rightValue)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user