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

Function getDoltgresTypeFromId

server/functions/enum.go:145–169  ·  view source on GitHub ↗

getDoltgresTypeFromId takes internal ID and returns the DoltgresType associated to it. It allows retrieving a user-defined type, and it requires a valid sql.Context.

(ctx *sql.Context, rawId id.Id)

Source from the content-addressed store, hash-verified

143// getDoltgresTypeFromId takes internal ID and returns the DoltgresType associated to it. It allows retrieving a
144// user-defined type, and it requires a valid sql.Context.
145func getDoltgresTypeFromId(ctx *sql.Context, rawId id.Id) (*pgtypes.DoltgresType, error) {
146 typCol, err := core.GetTypesCollectionFromContext(ctx, "")
147 if err != nil {
148 return nil, err
149 }
150 typID := id.Type(rawId)
151
152 schName := typID.SchemaName()
153 if schName == "" {
154 schName, err = core.GetCurrentSchema(ctx)
155 if err != nil {
156 return nil, err
157 }
158 }
159
160 typName := typID.TypeName()
161 typ, err := typCol.GetType(ctx, id.NewType(schName, typName))
162 if err != nil {
163 return nil, err
164 }
165 if typ == nil {
166 return nil, pgtypes.ErrTypeDoesNotExist.New(typName)
167 }
168 return typ, nil
169}

Callers 1

enum.goFile · 0.85

Calls 7

TypeTypeAlias · 0.92
GetCurrentSchemaFunction · 0.92
NewTypeFunction · 0.92
TypeNameMethod · 0.80
GetTypeMethod · 0.65
SchemaNameMethod · 0.45

Tested by

no test coverage detected