arrayToJsonRaw converts an anyarray to a JSON byte slice.
(ctx *sql.Context, arrType *pgtypes.DoltgresType, arr []any)
| 72 | |
| 73 | // arrayToJsonRaw converts an anyarray to a JSON byte slice. |
| 74 | func arrayToJsonRaw(ctx *sql.Context, arrType *pgtypes.DoltgresType, arr []any) (json.RawMessage, error) { |
| 75 | baseType := arrType.ArrayBaseType() |
| 76 | elements := make([]json.RawMessage, len(arr)) |
| 77 | for i, el := range arr { |
| 78 | raw, err := valueToJsonRaw(ctx, baseType, el) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | elements[i] = raw |
| 83 | } |
| 84 | return json.Marshal(elements) |
| 85 | } |
| 86 | |
| 87 | // valueToJsonRaw converts a single value to a JSON byte slice. |
| 88 | func valueToJsonRaw(ctx *sql.Context, elemType *pgtypes.DoltgresType, val any) (json.RawMessage, error) { |
no test coverage detected