-
Here is the query: if err = queries.Raw(
`SELECT count(id) as 'active', IFNULL(sum(balance), 0) as 'balance_value' FROM things WHERE balance>0`
).Bind(ctx, databaseRead, stats); err != nil {
return
} Here is the struct I am binding to: type TotalStatistics struct {
Active uint64 `json:"active" boil:"active"`
Balance float64 `json:"balance"`
BalanceValue uint64 `json:"balance_value" boil:"balance_value"`
Total uint64 `json:"total" boil:"total"`
TotalEarnedValue uint64 `json:"total_earned_value" boil:"total_earned_value"`
TotalEarned float64 `json:"total_earned"`
} However here is the error I am getting:
I would love some suggestions if there is a better solution. I am not sure why its not binding as a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This seems like there may be some witchcraft inside the MySQL driver that's doing this. Because in Go there is no real support for uint64 inside the drivers: https://golang.org/pkg/database/sql/driver/#Value I think that it might be automatically converting the value to a string and when it gets to sqlboiler it sees a string (note it's a slice of []uint8 aka []byte) and then it errors. Your best bet is to use a string to ensure that the full range of values is supported by your driver I think. |
Beta Was this translation helpful? Give feedback.
This seems like there may be some witchcraft inside the MySQL driver that's doing this.
Because in Go there is no real support for uint64 inside the drivers: https://golang.org/pkg/database/sql/driver/#Value I think that it might be automatically converting the value to a string and when it gets to sqlboiler it sees a string (note it's a slice of []uint8 aka []byte) and then it errors. Your best bet is to use a string to ensure that the full range of values is supported by your driver I think.