NormalizeIntsAndFloats normalizes all int and float types to int64 and float64, respectively.
(v any)
| 820 | // NormalizeIntsAndFloats normalizes all int and float types |
| 821 | // to int64 and float64, respectively. |
| 822 | func 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. |
| 856 | func Numeric(str string) pgtype.Numeric { |
no outgoing calls
no test coverage detected