fix: coerce booleans to numbers for comparison in exprparser (#1030)

Co-Authored-By: Markus Wolf <[email protected]>

Co-authored-by: Markus Wolf <[email protected]>
Co-authored-by: Casey Lee <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-03-14 16:38:42 +00:00
1 parent 14c98015c5
commit aab2af0919
2 files changed
+7 -1

No files matched your search

+3 -1
View File
@@ -305,6 +305,8 @@ func (impl *interperterImpl) compareValues(leftValue reflect.Value, rightValue r
}
switch leftValue.Kind() {
case reflect.Bool:
return impl.compareNumber(float64(impl.coerceToNumber(leftValue).Int()), float64(impl.coerceToNumber(rightValue).Int()), kind)
case reflect.String:
return impl.compareString(strings.ToLower(leftValue.String()), strings.ToLower(rightValue.String()), kind)
@@ -323,7 +325,7 @@ func (impl *interperterImpl) compareValues(leftValue reflect.Value, rightValue r
return impl.compareNumber(leftValue.Float(), rightValue.Float(), kind)
default:
return nil, fmt.Errorf("TODO: evaluateCompare not implemented %+v", reflect.TypeOf(leftValue))
return nil, fmt.Errorf("TODO: evaluateCompare not implemented! left: %+v, right: %+v", leftValue.Kind(), rightValue.Kind())
}
}