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.
()
| 1873 | // TODO(andyk): It'd be nice to have this return SqlString() method output, |
| 1874 | // since that is more descriptive. |
| 1875 | func (t *T) String() string { |
| 1876 | switch t.Family() { |
| 1877 | case CollatedStringFamily: |
| 1878 | if t.Locale() == "" { |
| 1879 | // Used in telemetry. |
| 1880 | return fmt.Sprintf("collated%s{*}", t.Name()) |
| 1881 | } |
| 1882 | return fmt.Sprintf("collated%s{%s}", t.Name(), t.Locale()) |
| 1883 | |
| 1884 | case ArrayFamily: |
| 1885 | switch t.Oid() { |
| 1886 | case oid.T_oidvector, oid.T_int2vector: |
| 1887 | return t.Name() |
| 1888 | } |
| 1889 | return t.ArrayContents().String() + "[]" |
| 1890 | |
| 1891 | case TupleFamily: |
| 1892 | var buf bytes.Buffer |
| 1893 | buf.WriteString("tuple") |
| 1894 | if len(t.TupleContents()) != 0 && !IsWildcardTupleType(t) { |
| 1895 | buf.WriteByte('{') |
| 1896 | for i, typ := range t.TupleContents() { |
| 1897 | if i != 0 { |
| 1898 | buf.WriteString(", ") |
| 1899 | } |
| 1900 | buf.WriteString(typ.String()) |
| 1901 | if t.TupleLabels() != nil { |
| 1902 | buf.WriteString(" AS ") |
| 1903 | buf.WriteString(t.InternalType.TupleLabels[i]) |
| 1904 | } |
| 1905 | } |
| 1906 | buf.WriteByte('}') |
| 1907 | } |
| 1908 | return buf.String() |
| 1909 | case IntervalFamily, TimestampFamily, TimestampTZFamily, TimeFamily, TimeTZFamily: |
| 1910 | if t.InternalType.Precision > 0 || t.InternalType.TimePrecisionIsSet { |
| 1911 | return fmt.Sprintf("%s(%d)", t.Name(), t.Precision()) |
| 1912 | } |
| 1913 | } |
| 1914 | return t.Name() |
| 1915 | } |
| 1916 | |
| 1917 | // DebugString returns a detailed dump of the type protobuf struct, suitable for |
| 1918 | // debugging scenarios. |
nothing calls this directly
no test coverage detected