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

Function NormalizeArrayType

testing/go/framework.go:739–758  ·  view source on GitHub ↗

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

(dt *types.DoltgresType, arr []any)

Source from the content-addressed store, hash-verified

737// NormalizeArrayType normalizes array types by normalizing its elements first,
738// then to a string using the type IoOutput method.
739func NormalizeArrayType(dt *types.DoltgresType, arr []any) any {
740 newVal := make([]any, len(arr))
741 for i, el := range arr {
742 newVal[i] = NormalizeVal(dt.ArrayBaseType(), el)
743 }
744 baseType := dt.ArrayBaseType()
745 if baseType.ID == types.Bool.ID {
746 sqlVal, err := dt.SQL(sql.NewEmptyContext(), nil, newVal)
747 if err != nil {
748 panic(err)
749 }
750 return sqlVal.ToString()
751 } else {
752 ret, err := dt.FormatValue(newVal)
753 if err != nil {
754 panic(err)
755 }
756 return ret
757 }
758}
759
760// NormalizeVal normalizes values to the Doltgres type expects, so it can be used to
761// convert the values using the given Doltgres type. This is used to normalize array

Callers 1

NormalizeValToStringFunction · 0.85

Calls 4

NormalizeValFunction · 0.85
ArrayBaseTypeMethod · 0.80
SQLMethod · 0.80
FormatValueMethod · 0.80

Tested by

no test coverage detected