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)
| 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. |
| 145 | func 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 | } |
no test coverage detected