GetCastsCollectionFromContext returns the given casts collection from the context. Will always return a collection if no error is returned.
(ctx *sql.Context, database string)
| 444 | // GetCastsCollectionFromContext returns the given casts collection from the context. |
| 445 | // Will always return a collection if no error is returned. |
| 446 | func GetCastsCollectionFromContext(ctx *sql.Context, database string) (*casts.Collection, error) { |
| 447 | cv, err := getContextValues(ctx) |
| 448 | if err != nil { |
| 449 | return nil, err |
| 450 | } |
| 451 | if cv.casts == nil { |
| 452 | cv.casts = make(map[string]*casts.Collection) |
| 453 | } |
| 454 | if len(database) == 0 { |
| 455 | database = ctx.GetCurrentDatabase() |
| 456 | } |
| 457 | if cv.casts[database] == nil { |
| 458 | _, root, err := getRootFromContextForDatabase(ctx, database) |
| 459 | if err != nil { |
| 460 | return nil, err |
| 461 | } |
| 462 | cv.casts[database], err = casts.LoadCasts(ctx, root) |
| 463 | if err != nil { |
| 464 | return nil, err |
| 465 | } |
| 466 | } |
| 467 | return cv.casts[database], nil |
| 468 | } |
| 469 | |
| 470 | // CloseContextRootFinalizer finalizes any changes persisted within the context by writing them to the working root. |
| 471 | // This should ONLY be called by the ContextRootFinalizer node. |
no test coverage detected