MCPcopy Create free account
hub / github.com/apecloud/myduckserver / NormalizeArrayType

Function NormalizeArrayType

pgtest/framework.go:244–255  ·  view source on GitHub ↗

NormalizeArrayType normalizes array types by normalizing its elements first, then to a string using the type IoOutput method.

(dta *pgtype.Type, arr []any)

Source from the content-addressed store, hash-verified

242// NormalizeArrayType normalizes array types by normalizing its elements first,
243// then to a string using the type IoOutput method.
244func NormalizeArrayType(dta *pgtype.Type, arr []any) any {
245 baseType := dta.Codec.(*pgtype.ArrayCodec).ElementType
246 newVal := make([]any, len(arr))
247 for i, el := range arr {
248 newVal[i] = NormalizeVal(baseType, el)
249 }
250 bytes, err := defaultMap.Encode(dta.OID, pgtype.TextFormatCode, newVal, nil)
251 if err != nil {
252 panic(err)
253 }
254 return string(bytes)
255}
256
257// NormalizeVal normalizes values to the Doltgres type expects, so it can be used to
258// convert the values using the given Doltgres type. This is used to normalize array

Callers 1

NormalizeValToStringFunction · 0.85

Calls 2

NormalizeValFunction · 0.85
EncodeMethod · 0.45

Tested by

no test coverage detected