| 249 | } |
| 250 | |
| 251 | func (handler *integerHandler) decode(property *schema.Property, data interface{}) (res interface{}, err error) { |
| 252 | // different SQL drivers encode result with different type |
| 253 | // so we need to do manual checks |
| 254 | if data == nil { |
| 255 | return nil, nil |
| 256 | } |
| 257 | switch t := data.(type) { |
| 258 | default: |
| 259 | return data, nil |
| 260 | case []uint8: // mysql |
| 261 | res, _ = strconv.ParseInt(string(t), 10, 64) |
| 262 | res = int(res.(int64)) |
| 263 | case int64: // sqlite3 |
| 264 | res = int(t) |
| 265 | } |
| 266 | return |
| 267 | } |
| 268 | |
| 269 | func (handler *integerHandler) dataType(property *schema.Property) string { |
| 270 | return "numeric" |