(val any, setScale bool, scale int32)
| 290 | } |
| 291 | |
| 292 | func numeric(val any, setScale bool, scale int32) (*apd.Decimal, error) { |
| 293 | switch val.(type) { |
| 294 | case int64, float64: |
| 295 | // expects these types to Scan from |
| 296 | default: |
| 297 | return nil, cerrors.Errorf("invalid type for numeric convert: %T", val) |
| 298 | } |
| 299 | dec := new(apd.Decimal) |
| 300 | err := dec.Scan(val) |
| 301 | if err != nil { |
| 302 | return nil, err |
| 303 | } |
| 304 | |
| 305 | if setScale { |
| 306 | dec, err = sql.DecimalRound(dec, scale) |
| 307 | if err != nil { |
| 308 | return nil, err |
| 309 | } |
| 310 | } |
| 311 | return dec, nil |
| 312 | } |
no test coverage detected