Ensure boolean expressions return actual value not boolean value
This commit is contained in:
parent
eeaaaf4ec9
commit
66ee13a52d
1 changed files with 10 additions and 5 deletions
15
db/fetch.go
15
db/fetch.go
|
@ -525,14 +525,19 @@ func calcAsMath(i interface{}) float64 {
|
|||
|
||||
func binaryBool(op sql.Token, l, r interface{}) interface{} {
|
||||
|
||||
a := calcAsBool(l)
|
||||
b := calcAsBool(r)
|
||||
|
||||
switch op {
|
||||
case sql.AND:
|
||||
return a && b
|
||||
if calcAsBool(l) && calcAsBool(r) {
|
||||
return l
|
||||
} else {
|
||||
return r
|
||||
}
|
||||
case sql.OR:
|
||||
return a || b
|
||||
if calcAsBool(l) {
|
||||
return l
|
||||
} else {
|
||||
return r
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue