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

Method ColumnTypeScanType

stdlib/sql.go:697–722  ·  view source on GitHub ↗

ColumnTypeScanType returns the value type that can be used to scan types into.

(index int)

Source from the content-addressed store, hash-verified

695
696// ColumnTypeScanType returns the value type that can be used to scan types into.
697func (r *Rows) ColumnTypeScanType(index int) reflect.Type {
698 fd := r.rows.FieldDescriptions()[index]
699
700 switch fd.DataTypeOID {
701 case pgtype.Float8OID:
702 return reflect.TypeFor[float64]()
703 case pgtype.Float4OID:
704 return reflect.TypeFor[float32]()
705 case pgtype.Int8OID:
706 return reflect.TypeFor[int64]()
707 case pgtype.Int4OID:
708 return reflect.TypeFor[int32]()
709 case pgtype.Int2OID:
710 return reflect.TypeFor[int16]()
711 case pgtype.BoolOID:
712 return reflect.TypeFor[bool]()
713 case pgtype.NumericOID:
714 return reflect.TypeFor[float64]()
715 case pgtype.DateOID, pgtype.TimestampOID, pgtype.TimestamptzOID:
716 return reflect.TypeFor[time.Time]()
717 case pgtype.ByteaOID:
718 return reflect.TypeFor[[]byte]()
719 default:
720 return reflect.TypeFor[string]()
721 }
722}
723
724func (r *Rows) Close() error {
725 r.rows.Close()

Callers

nothing calls this directly

Implementers 3

baseRowsrows.go
errRowspgxpool/rows.go
poolRowspgxpool/rows.go

Calls 1

FieldDescriptionsMethod · 0.65

Tested by

no test coverage detected