String returns the name of the type, similar to the Name method. However, it expands CollatedStringFamily, ArrayFamily, and TupleFamily types to be more descriptive. TODO(andyk): It'd be nice to have this return SqlString() method output, since that is more descriptive.
()
| 2242 | // TODO(andyk): It'd be nice to have this return SqlString() method output, |
| 2243 | // since that is more descriptive. |
| 2244 | func (t *T) String() string { |
| 2245 | switch t.Family() { |
| 2246 | case CollatedStringFamily: |
| 2247 | if t.Locale() == "" { |
| 2248 | // Used in telemetry. |
| 2249 | return fmt.Sprintf("collated%s{*}", t.Name()) |
| 2250 | } |
| 2251 | return fmt.Sprintf("collated%s{%s}", t.Name(), t.Locale()) |
| 2252 | |
| 2253 | case ArrayFamily: |
| 2254 | switch t.Oid() { |
| 2255 | case oid.T_oidvector, oid.T_int2vector: |
| 2256 | return t.Name() |
| 2257 | } |
| 2258 | return t.ArrayContents().String() + "[]" |
| 2259 | |
| 2260 | case TupleFamily: |
| 2261 | var buf bytes.Buffer |
| 2262 | buf.WriteString("tuple") |
| 2263 | if len(t.TupleContents()) != 0 && !IsWildcardTupleType(t) { |
| 2264 | buf.WriteByte('{') |
| 2265 | for i, typ := range t.TupleContents() { |
| 2266 | if i != 0 { |
| 2267 | buf.WriteString(", ") |
| 2268 | } |
| 2269 | buf.WriteString(typ.String()) |
| 2270 | if t.TupleLabels() != nil { |
| 2271 | buf.WriteString(" AS ") |
| 2272 | buf.WriteString(t.InternalType.TupleLabels[i]) |
| 2273 | } |
| 2274 | } |
| 2275 | buf.WriteByte('}') |
| 2276 | } |
| 2277 | return buf.String() |
| 2278 | case IntervalFamily, TimestampFamily, TimestampTZFamily, TimeFamily, TimeTZFamily: |
| 2279 | if t.InternalType.Precision > 0 || t.InternalType.TimePrecisionIsSet { |
| 2280 | return fmt.Sprintf("%s(%d)", t.Name(), t.Precision()) |
| 2281 | } |
| 2282 | } |
| 2283 | return t.Name() |
| 2284 | } |
| 2285 | |
| 2286 | // DebugString returns a detailed dump of the type protobuf struct, suitable for |
| 2287 | // debugging scenarios. |
nothing calls this directly
no test coverage detected