recursiveDeserializeType handles recursive type initialization by caching the type-in-progress and returning the target type. This also takes a TypeCollection so that it may be reused if multiple calls are made without having to fetch it at each instance.
(ctx *sql.Context, typ *DoltgresType, typeColl TypeCollection, target *DoltgresType)
| 258 | // target type. This also takes a TypeCollection so that it may be reused if multiple calls are made without having to |
| 259 | // fetch it at each instance. |
| 260 | func recursiveDeserializeType(ctx *sql.Context, typ *DoltgresType, typeColl TypeCollection, target *DoltgresType) (*DoltgresType, TypeCollection, error) { |
| 261 | if !target.IsUnresolved { |
| 262 | return target, typeColl, nil |
| 263 | } |
| 264 | var recursedType *DoltgresType |
| 265 | var err error |
| 266 | if typeColl == nil { |
| 267 | typeColl, err = GetTypesCollectionFromContext(ctx, "") |
| 268 | if err != nil { |
| 269 | return nil, nil, err |
| 270 | } |
| 271 | } |
| 272 | typeColl.WithCachedType(typ, func() { |
| 273 | t, nErr := typeColl.GetType(ctx, target.ID) |
| 274 | recursedType = t |
| 275 | err = nErr |
| 276 | }) |
| 277 | // `GetType` returns a nil type if it cannot be found, so we want to error in that case |
| 278 | if err == nil && recursedType == nil { |
| 279 | return target, typeColl, errors.Errorf("unable to resolve type `%s` during deserialization", target.ID.TypeName()) |
| 280 | } |
| 281 | return recursedType, typeColl, err |
| 282 | } |
no test coverage detected