MCPcopy Create free account
hub / github.com/dolthub/doltgresql / numeric

Function numeric

server/functions/extract.go:292–312  ·  view source on GitHub ↗
(val any, setScale bool, scale int32)

Source from the content-addressed store, hash-verified

290}
291
292func 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}

Callers 2

extract.goFile · 0.85
getFieldFromTimeValFunction · 0.85

Calls 2

ErrorfMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected