Tweak expr record value selection and bool casting
* properly handle casting of false values (empty string) * add support for record.values.xyz expressions where values is not set
This commit is contained in:
@@ -7,6 +7,12 @@ import (
|
||||
"github.com/PaesslerAG/gval"
|
||||
)
|
||||
|
||||
type (
|
||||
empty interface {
|
||||
IsEmpty() bool
|
||||
}
|
||||
)
|
||||
|
||||
func GenericFunctions() []gval.Language {
|
||||
return []gval.Language{
|
||||
gval.Function("coalesce", coalesce),
|
||||
@@ -57,6 +63,10 @@ func isEmpty(i interface{}) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if c, ok := i.(empty); ok {
|
||||
return c.IsEmpty()
|
||||
}
|
||||
|
||||
switch reflect.TypeOf(i).Kind() {
|
||||
case reflect.Slice, reflect.Array, reflect.Map:
|
||||
return reflect.ValueOf(i).Len() == 0
|
||||
|
||||
Reference in New Issue
Block a user