Value implements the driver.Valuer interface.
()
| 842 | |
| 843 | // Value implements the driver.Valuer interface. |
| 844 | func (a GenericArray) Value() (driver.Value, error) { |
| 845 | if a.A == nil { |
| 846 | return nil, nil |
| 847 | } |
| 848 | |
| 849 | rv := reflect.ValueOf(a.A) |
| 850 | |
| 851 | switch rv.Kind() { |
| 852 | case reflect.Slice: |
| 853 | if rv.IsNil() { |
| 854 | return nil, nil |
| 855 | } |
| 856 | case reflect.Array: |
| 857 | default: |
| 858 | return nil, fmt.Errorf("boil: Unable to convert %T to array", a.A) |
| 859 | } |
| 860 | |
| 861 | if n := rv.Len(); n > 0 { |
| 862 | // There will be at least two curly brackets, N bytes of values, |
| 863 | // and N-1 bytes of delimiters. |
| 864 | b := make([]byte, 0, 1+2*n) |
| 865 | |
| 866 | b, _, err := appendArray(b, rv, n) |
| 867 | return string(b), err |
| 868 | } |
| 869 | |
| 870 | return "{}", nil |
| 871 | } |
| 872 | |
| 873 | // Int64Array represents a one-dimensional array of the PostgreSQL integer types. |
| 874 | type Int64Array []int64 |