Ensure boolean expressions return actual value not boolean value

This commit is contained in:
Tobie Morgan Hitchcock 2020-11-23 19:25:11 +00:00
parent eeaaaf4ec9
commit 66ee13a52d

View file

@ -525,14 +525,19 @@ func calcAsMath(i interface{}) float64 {
func binaryBool(op sql.Token, l, r interface{}) interface{} { func binaryBool(op sql.Token, l, r interface{}) interface{} {
a := calcAsBool(l)
b := calcAsBool(r)
switch op { switch op {
case sql.AND: case sql.AND:
return a && b if calcAsBool(l) && calcAsBool(r) {
return l
} else {
return r
}
case sql.OR: case sql.OR:
return a || b if calcAsBool(l) {
return l
} else {
return r
}
} }
return nil return nil