mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
ensure provided min/max are valid
This commit is contained in:
parent
f7fb9f386e
commit
739fd9b04b
1 changed files with 21 additions and 10 deletions
|
|
@ -1577,18 +1577,29 @@ func fieldOptionsToFunctionalOpts(opt fieldOptions) []FieldOption {
|
|||
if opt.Scale != nil {
|
||||
scale = *opt.Scale
|
||||
min, max := pql.MinMax(scale)
|
||||
opt.Min = &min
|
||||
opt.Max = &max
|
||||
} else {
|
||||
|
||||
if opt.Min == nil {
|
||||
min := pql.NewDecimal(int64(math.MinInt64), scale)
|
||||
opt.Min = &min
|
||||
}
|
||||
if opt.Max == nil {
|
||||
max := pql.NewDecimal(int64(math.MaxInt64), scale)
|
||||
// ensure the provided bounds are valid
|
||||
if opt.Max != nil && max.LessThan(*opt.Max) {
|
||||
opt.Max = &max
|
||||
}
|
||||
if opt.Max == nil {
|
||||
opt.Max = &max
|
||||
}
|
||||
|
||||
if opt.Min != nil && min.GreaterThan(*opt.Min) {
|
||||
opt.Min = &min
|
||||
}
|
||||
if opt.Min == nil {
|
||||
opt.Min = &min
|
||||
}
|
||||
}
|
||||
|
||||
if opt.Min == nil {
|
||||
min := pql.NewDecimal(int64(math.MinInt64), scale)
|
||||
opt.Min = &min
|
||||
}
|
||||
if opt.Max == nil {
|
||||
max := pql.NewDecimal(int64(math.MaxInt64), scale)
|
||||
opt.Max = &max
|
||||
}
|
||||
var minmax []pql.Decimal
|
||||
if opt.Min != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue