IoOutput converts given type value to output string.
(ctx *sql.Context, val any)
| 620 | |
| 621 | // IoOutput converts given type value to output string. |
| 622 | func (t *DoltgresType) IoOutput(ctx *sql.Context, val any) (string, error) { |
| 623 | var o any |
| 624 | var err error |
| 625 | if t.ModInFunc != 0 || t.IsArrayType() || t.IsCompositeType() { |
| 626 | send := globalFunctionRegistry.GetFunction(ctx, t.OutputFunc) |
| 627 | resolvedTypes := send.ResolvedTypes() |
| 628 | resolvedTypes[0] = t |
| 629 | o, err = send.WithResolvedTypes(resolvedTypes).(QuickFunction).CallVariadic(ctx, val) |
| 630 | } else { |
| 631 | o, err = globalFunctionRegistry.GetFunction(ctx, t.OutputFunc).CallVariadic(ctx, val) |
| 632 | } |
| 633 | if err != nil { |
| 634 | return "", err |
| 635 | } |
| 636 | var ok bool |
| 637 | os, ok, err := sql.Unwrap[string](ctx, o) |
| 638 | if !ok { |
| 639 | return "", errors.Errorf("unexpected type for io output, expected string, got %T", val) |
| 640 | } |
| 641 | return os, err |
| 642 | } |
| 643 | |
| 644 | // IsArrayType returns true if the type is of 'array' type. |
| 645 | // It can be array category with empty its array attribute NULL and element attribute NOT NULL. |
no test coverage detected