Name returns a single word description of the type that describes it succinctly, but without all the details, such as width, locale, etc. The name is sometimes the same as the name returned by SQLStandardName, but is more CRDB friendly. TODO(andyk): Should these be changed to be the same as SQLStan
()
| 992 | // |
| 993 | // TODO(andyk): Should these be changed to be the same as SQLStandardName? |
| 994 | func (t *T) Name() string { |
| 995 | switch t.Family() { |
| 996 | case AnyFamily: |
| 997 | return "anyelement" |
| 998 | case ArrayFamily: |
| 999 | switch t.Oid() { |
| 1000 | case oid.T_oidvector: |
| 1001 | return "oidvector" |
| 1002 | case oid.T_int2vector: |
| 1003 | return "int2vector" |
| 1004 | } |
| 1005 | return t.ArrayContents().Name() + "[]" |
| 1006 | case BitFamily: |
| 1007 | if t.Oid() == oid.T_varbit { |
| 1008 | return "varbit" |
| 1009 | } |
| 1010 | return "bit" |
| 1011 | case BoolFamily: |
| 1012 | return "bool" |
| 1013 | case BytesFamily: |
| 1014 | return "bytes" |
| 1015 | case DateFamily: |
| 1016 | return "date" |
| 1017 | case DecimalFamily: |
| 1018 | return "decimal" |
| 1019 | case FloatFamily: |
| 1020 | switch t.Width() { |
| 1021 | case 64: |
| 1022 | return "float" |
| 1023 | case 32: |
| 1024 | return "float4" |
| 1025 | default: |
| 1026 | panic(errors.AssertionFailedf("programming error: unknown float width: %d", t.Width())) |
| 1027 | } |
| 1028 | case INetFamily: |
| 1029 | return "inet" |
| 1030 | case IntFamily: |
| 1031 | switch t.Width() { |
| 1032 | case 64: |
| 1033 | return "int" |
| 1034 | case 32: |
| 1035 | return "int4" |
| 1036 | case 16: |
| 1037 | return "int2" |
| 1038 | default: |
| 1039 | panic(errors.AssertionFailedf("programming error: unknown int width: %d", t.Width())) |
| 1040 | } |
| 1041 | case IntervalFamily: |
| 1042 | return "interval" |
| 1043 | case JsonFamily: |
| 1044 | return "jsonb" |
| 1045 | case OidFamily: |
| 1046 | return t.SQLStandardName() |
| 1047 | case StringFamily, CollatedStringFamily: |
| 1048 | switch t.Oid() { |
| 1049 | case oid.T_text: |
| 1050 | return "string" |
| 1051 | case oid.T_bpchar: |
no test coverage detected