MCPcopy
hub / github.com/PeerDB-io/peerdb / BuildColumnSchemaMap

Function BuildColumnSchemaMap

flow/pkg/postgres/dest_validation.go:73–87  ·  view source on GitHub ↗

BuildColumnSchemaMap assembles a ColumnSchema map from pgx FieldDescriptions.

(
	fields []pgconn.FieldDescription,
	typeMap *pgtype.Map,
	customTypeMapping map[uint32]CustomDataType,
)

Source from the content-addressed store, hash-verified

71
72// BuildColumnSchemaMap assembles a ColumnSchema map from pgx FieldDescriptions.
73func BuildColumnSchemaMap(
74 fields []pgconn.FieldDescription,
75 typeMap *pgtype.Map,
76 customTypeMapping map[uint32]CustomDataType,
77) (map[string]ColumnSchema, error) {
78 columns := make(map[string]ColumnSchema, len(fields))
79 for _, fd := range fields {
80 typeName, err := OIDToName(typeMap, fd.DataTypeOID, customTypeMapping)
81 if err != nil {
82 return nil, fmt.Errorf("failed to resolve type for column %s: %w", fd.Name, err)
83 }
84 columns[fd.Name] = ColumnSchema{TypeName: typeName, TypeMod: fd.TypeModifier}
85 }
86 return columns, nil
87}
88
89// ColumnMapping holds a source→destination column name pair for rename resolution.
90type ColumnMapping struct {

Callers 1

Calls 1

OIDToNameFunction · 0.85

Tested by

no test coverage detected