MCPcopy
hub / github.com/sqlc-dev/sqlc / formatType

Method formatType

internal/engine/postgresql/analyzer/analyze.go:128–144  ·  view source on GitHub ↗

TODO: Use PGX to do the lookup for basic OID types

(ctx context.Context, oid uint32, modifier int32)

Source from the content-addressed store, hash-verified

126
127// TODO: Use PGX to do the lookup for basic OID types
128func (a *Analyzer) formatType(ctx context.Context, oid uint32, modifier int32) (string, error) {
129 key := formatKey{oid, modifier}
130 ftyp, ok := a.formats.Load(key)
131 if ok {
132 return ftyp.(string), nil
133 }
134 rows, err := a.pool.Query(ctx, `SELECT format_type($1, $2)`, oid, modifier)
135 if err != nil {
136 return "", err
137 }
138 dt, err := pgx.CollectOneRow(rows, pgx.RowTo[string])
139 if err != nil {
140 return "", err
141 }
142 a.formats.Store(key, dt)
143 return dt, err
144}
145
146// TODO: This is bad
147func rewriteType(dt string) string {

Callers 1

AnalyzeMethod · 0.95

Implementers 3

CachedAnalyzerinternal/analyzer/analyzer.go
Analyzerinternal/engine/postgresql/analyzer/an
Analyzerinternal/engine/sqlite/analyzer/analyz

Calls 1

QueryMethod · 0.65

Tested by

no test coverage detected