ToArrayType returns an array type of given base type. For array types, ToArrayType causes them to return themselves.
()
| 934 | // ToArrayType returns an array type of given base type. |
| 935 | // For array types, ToArrayType causes them to return themselves. |
| 936 | func (t *DoltgresType) ToArrayType() *DoltgresType { |
| 937 | if t.IsArrayType() { |
| 938 | return t |
| 939 | } |
| 940 | if t.Array.IsResolvedType() { |
| 941 | arr := t.Array.WithAttTypMod(t.attTypMod) |
| 942 | arr.InternalName = fmt.Sprintf("%s[]", t.String()) |
| 943 | return arr |
| 944 | } |
| 945 | if t.Array.ID == id.NullType { |
| 946 | // Unresolved or stub type: derive an unresolved array type using the Postgres naming convention. |
| 947 | // The caller (e.g. during plan-building before the analyzer resolves types) will re-invoke |
| 948 | // ToArrayType on the fully-resolved base type once the analyzer has run. |
| 949 | return NewUnresolvedArrayDoltgresType(t.ID.SchemaName(), t.ID.TypeName()) |
| 950 | } |
| 951 | // User-defined type: the array type is not in the built-in map, so build it from this base type. |
| 952 | return CreateArrayTypeFromBaseType(t) |
| 953 | // TODO: delete the commented out code below, only exists for referencing |
| 954 | /*arr, ok := IDToBuiltInDoltgresType[t.Array] |
| 955 | if !ok { |
| 956 | if t.Array.ID == id.NullType { |
| 957 | // Unresolved or stub type: derive an unresolved array type using the Postgres naming convention. |
| 958 | // The caller (e.g. during plan-building before the analyzer resolves types) will re-invoke |
| 959 | // ToArrayType on the fully-resolved base type once the analyzer has run. |
| 960 | return NewUnresolvedArrayDoltgresType(t.ID.SchemaName(), t.ID.TypeName()) |
| 961 | } |
| 962 | // User-defined type: the array type is not in the built-in map, so build it from this base type. |
| 963 | return CreateArrayTypeFromBaseType(t) |
| 964 | } |
| 965 | newArr := *arr.WithAttTypMod(t.attTypMod) |
| 966 | newArr.InternalName = fmt.Sprintf("%s[]", t.String()) |
| 967 | return &newArr*/ |
| 968 | } |
| 969 | |
| 970 | // Type implements the types.ExtendedType interface. |
| 971 | func (t *DoltgresType) Type() query.Type { |
no test coverage detected