interval: the IN operator can now check if an integer value is inlcuded in a range
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user