MCPcopy
hub / github.com/jackc/pgx / Scan

Method Scan

pgtype/numeric.go:786–808  ·  view source on GitHub ↗
(src []byte, dst any)

Source from the content-addressed store, hash-verified

784type scanPlanTextAnyToNumericScanner struct{}
785
786func (scanPlanTextAnyToNumericScanner) Scan(src []byte, dst any) error {
787 scanner := (dst).(NumericScanner)
788
789 if src == nil {
790 return scanner.ScanNumeric(Numeric{})
791 }
792
793 switch string(src) {
794 case "NaN":
795 return scanner.ScanNumeric(Numeric{NaN: true, Valid: true})
796 case "Infinity":
797 return scanner.ScanNumeric(Numeric{InfinityModifier: Infinity, Valid: true})
798 case "-Infinity":
799 return scanner.ScanNumeric(Numeric{InfinityModifier: NegativeInfinity, Valid: true})
800 }
801
802 num, exp, err := parseNumericString(string(src))
803 if err != nil {
804 return err
805 }
806
807 return scanner.ScanNumeric(Numeric{Int: num, Exp: exp, Valid: true})
808}
809
810func (c NumericCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16, src []byte) (driver.Value, error) {
811 if src == nil {

Callers

nothing calls this directly

Calls 2

parseNumericStringFunction · 0.85
ScanNumericMethod · 0.65

Tested by

no test coverage detected