Przeglądaj źródła

Handle nil source values in Scan

Fixes #396
Gary Burd 6 lat temu
rodzic
commit
43fe51054a
2 zmienionych plików z 4 dodań i 0 usunięć
  1. 2 0
      redis/scan.go
  2. 2 0
      redis/scan_test.go

+ 2 - 0
redis/scan.go

@@ -44,6 +44,8 @@ func cannotConvert(d reflect.Value, s interface{}) error {
 		sname = "Redis bulk string"
 	case []interface{}:
 		sname = "Redis array"
+	case nil:
+		sname = "Redis nil"
 	default:
 		sname = reflect.TypeOf(s).String()
 	}

+ 2 - 0
redis/scan_test.go

@@ -72,6 +72,8 @@ var scanConversionTests = []struct {
 	{"hello", "hello"},
 	{[]byte("hello"), "hello"},
 	{[]byte("world"), []byte("world")},
+	{nil, ""},
+	{nil, []byte(nil)},
 
 	{[]interface{}{[]byte("b1")}, []interface{}{[]byte("b1")}},
 	{[]interface{}{[]byte("b2")}, []string{"b2"}},