MCPcopy Create free account
hub / github.com/dolthub/doltgresql / ToArrayType

Method ToArrayType

server/types/type.go:936–968  ·  view source on GitHub ↗

ToArrayType returns an array type of given base type. For array types, ToArrayType causes them to return themselves.

()

Source from the content-addressed store, hash-verified

934// ToArrayType returns an array type of given base type.
935// For array types, ToArrayType causes them to return themselves.
936func (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.
971func (t *DoltgresType) Type() query.Type {

Callers 7

overloadsForParamsMethod · 0.80
TypeMethod · 0.80
getTargetTypeMethod · 0.80
TypeMethod · 0.80
WithChildrenMethod · 0.80

Calls 8

IsArrayTypeMethod · 0.95
StringMethod · 0.95
IsResolvedTypeMethod · 0.80
WithAttTypModMethod · 0.80
TypeNameMethod · 0.80
SchemaNameMethod · 0.45

Tested by

no test coverage detected