getStringArrFromAnyArray takes inputs of any array, delimiter and null entry replacement. It uses the IoOutput() of the base type of the AnyArray type to get string representation of array elements.
(ctx *sql.Context, arrType *pgtypes.DoltgresType, arr []any, delimiter string, nullEntry any)
| 66 | // getStringArrFromAnyArray takes inputs of any array, delimiter and null entry replacement. It uses the IoOutput() of the |
| 67 | // base type of the AnyArray type to get string representation of array elements. |
| 68 | func getStringArrFromAnyArray(ctx *sql.Context, arrType *pgtypes.DoltgresType, arr []any, delimiter string, nullEntry any) (string, error) { |
| 69 | baseType := arrType.ArrayBaseType() |
| 70 | strs := make([]string, 0) |
| 71 | for _, el := range arr { |
| 72 | if el != nil { |
| 73 | v, err := baseType.IoOutput(ctx, el) |
| 74 | if err != nil { |
| 75 | return "", err |
| 76 | } |
| 77 | strs = append(strs, v) |
| 78 | } else if nullEntry != nil { |
| 79 | strs = append(strs, nullEntry.(string)) |
| 80 | } |
| 81 | } |
| 82 | return strings.Join(strs, delimiter), nil |
| 83 | } |
no test coverage detected