| 955 | } |
| 956 | |
| 957 | func TestGenericArrayScanUnsupported(t *testing.T) { |
| 958 | var s string |
| 959 | var ss []string |
| 960 | var nsa [1]sql.NullString |
| 961 | |
| 962 | for _, tt := range []struct { |
| 963 | src, dest any |
| 964 | err string |
| 965 | }{ |
| 966 | {nil, nil, "destination <nil> is not a pointer to array or slice"}, |
| 967 | {nil, true, "destination bool is not a pointer to array or slice"}, |
| 968 | {nil, &s, "destination *string is not a pointer to array or slice"}, |
| 969 | {nil, ss, "destination []string is not a pointer to array or slice"}, |
| 970 | {nil, &nsa, "<nil> to [1]sql.NullString"}, |
| 971 | {true, &ss, "bool to []string"}, |
| 972 | {`{{x}}`, &ss, "multidimensional ARRAY[1][1] is not implemented"}, |
| 973 | {`{{x},{x}}`, &ss, "multidimensional ARRAY[2][1] is not implemented"}, |
| 974 | {`{x}`, &ss, "scanning to string is not implemented"}, |
| 975 | } { |
| 976 | err := GenericArray{tt.dest}.Scan(tt.src) |
| 977 | |
| 978 | if err == nil { |
| 979 | t.Fatalf("Expected error for [%#v %#v]", tt.src, tt.dest) |
| 980 | } |
| 981 | if !strings.Contains(err.Error(), tt.err) { |
| 982 | t.Errorf("Expected error to contain %q for [%#v %#v], got %q", tt.err, tt.src, tt.dest, err) |
| 983 | } |
| 984 | } |
| 985 | } |
| 986 | |
| 987 | func TestGenericArrayScanScannerArrayBytes(t *testing.T) { |
| 988 | src, expected, nsa := []byte(`{NULL,abc,"\""}`), |