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

Function NormalizeIntsAndFloats

testing/go/framework.go:822–853  ·  view source on GitHub ↗

NormalizeIntsAndFloats normalizes all int and float types to int64 and float64, respectively.

(v any)

Source from the content-addressed store, hash-verified

820// NormalizeIntsAndFloats normalizes all int and float types
821// to int64 and float64, respectively.
822func NormalizeIntsAndFloats(v any) any {
823 switch val := v.(type) {
824 case int:
825 return int64(val)
826 case int8:
827 return int64(val)
828 case int16:
829 return int64(val)
830 case int32:
831 return int64(val)
832 case uint:
833 return int64(val)
834 case uint8:
835 return int64(val)
836 case uint16:
837 return int64(val)
838 case uint32:
839 return int64(val)
840 case uint64:
841 // PostgreSQL does not support an uint64 type, so we can always convert this to an int64 safely.
842 return int64(val)
843 case float32:
844 return float64(val)
845 case []any:
846 for i := range val {
847 val[i] = NormalizeIntsAndFloats(val[i])
848 }
849 return val
850 default:
851 return val
852 }
853}
854
855// Numeric creates a numeric value from a string.
856func Numeric(str string) pgtype.Numeric {

Callers 2

NormalizeRowFunction · 0.85
NormalizeExpectedRowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected