MCPcopy Create free account
hub / github.com/dolthub/doltgresql / getStringArrFromAnyArray

Function getStringArrFromAnyArray

server/functions/array_to_string.go:68–83  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
68func 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}

Callers 1

array_to_string.goFile · 0.85

Calls 2

ArrayBaseTypeMethod · 0.80
IoOutputMethod · 0.80

Tested by

no test coverage detected