interval: the IN operator can now check if an integer value is inlcuded in a range

This commit is contained in:
2026-08-01 11:22:58 +02:00
parent 6f08176122
commit 481074d104
4 changed files with 19 additions and 2 deletions
+12
View File
@@ -8,6 +8,7 @@ import (
"fmt"
"git.portale-stac.it/go-pkg/expr/kern"
"git.portale-stac.it/go-pkg/expr/types"
)
const TypeName = "interval"
@@ -60,6 +61,17 @@ func (p *IntervalType) ToIntTriple() (b, e, s int) {
return
}
func (p *IntervalType) Contains(value any) (ok bool) {
if v, err := types.ToGoInt64(value, TypeName); err == nil {
if p.begin <= p.end {
ok = (v >= p.begin && v < p.end && (v-p.begin)%p.step == 0)
} else {
ok = (v <= p.begin && v > p.end && (v-p.begin)%p.step == 0)
}
}
return
}
// func (b *bool) EqualTo(other kern.Equaler) (equal bool) {
// if otherBool, ok := other.(*bool); ok {
// equal = b == otherBool