Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix coerce ToBool #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion data/coerce/primatives.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,25 @@ func ToBool(val interface{}) (bool, error) {
switch t := val.(type) {
case bool:
return t, nil
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
case int:
return t != 0, nil
case uint:
return t != 0, nil
case int8:
return t != 0, nil
case uint8:
return t != 0, nil
case int16:
return t != 0, nil
case uint16:
return t != 0, nil
case int32:
return t != 0, nil
case uint32:
return t != 0, nil
case int64:
return t != 0, nil
case uint64:
return t != 0, nil
case float64:
return t != 0.0, nil
Expand Down