MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / rewriteType

Function rewriteType

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

TODO: This is bad

(dt string)

Source from the content-addressed store, hash-verified

145
146// TODO: This is bad
147func rewriteType(dt string) string {
148 switch {
149 case strings.HasPrefix(dt, "character("):
150 return "pg_catalog.bpchar"
151 case strings.HasPrefix(dt, "character varying"):
152 return "pg_catalog.varchar"
153 case strings.HasPrefix(dt, "bit varying"):
154 return "pg_catalog.varbit"
155 case strings.HasPrefix(dt, "bit("):
156 return "pg_catalog.bit"
157 }
158 switch dt {
159 case "bpchar":
160 return "pg_catalog.bpchar"
161 case "timestamp without time zone":
162 return "pg_catalog.timestamp"
163 case "timestamp with time zone":
164 return "pg_catalog.timestamptz"
165 case "time without time zone":
166 return "pg_catalog.time"
167 case "time with time zone":
168 return "pg_catalog.timetz"
169 }
170 return dt
171}
172
173func parseType(dt string) (string, bool, int) {
174 size := 0

Callers 1

parseTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected