Correctly parse EVAL response containing customized error (#710)

* always parse all content in an array including error
This commit is contained in:
Huan Du 2018-02-16 19:39:56 +08:00 committed by Vladimir Mihailenco
parent daab7c60d0
commit 4598ed0eac
2 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
. "github.com/onsi/gomega"
"github.com/go-redis/redis"
"github.com/go-redis/redis/internal"
)
var _ = Describe("Commands", func() {
@ -2993,6 +2994,15 @@ var _ = Describe("Commands", func() {
Expect(vals).To(Equal([]interface{}{"key", "hello"}))
})
It("returns all values after an error", func() {
vals, err := client.Eval(
`return {12, {err="error"}, "abc"}`,
nil,
).Result()
Expect(err).NotTo(HaveOccurred())
Expect(vals).To(Equal([]interface{}{int64(12), internal.RedisError("error"), "abc"}))
})
})
})

View File

@ -17,7 +17,7 @@ func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
if err == Nil {
vals = append(vals, nil)
} else if err != nil {
return nil, err
vals = append(vals, err)
} else {
switch vv := v.(type) {
case []byte: