NormalizeArrayType normalizes array types by normalizing its elements first, then to a string using the type IoOutput method.
(dt *types.DoltgresType, arr []any)
| 737 | // NormalizeArrayType normalizes array types by normalizing its elements first, |
| 738 | // then to a string using the type IoOutput method. |
| 739 | func 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 |
no test coverage detected