Skip to content

Commit

Permalink
Correctly parse EVAL response containing customized error (redis#710)
Browse files Browse the repository at this point in the history
* always parse all content in an array including error
  • Loading branch information
huandu authored and vmihailenco committed Feb 16, 2018
1 parent daab7c6 commit 4598ed0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
. "github.com/onsi/gomega"

"github.com/go-redis/redis"
"github.com/go-redis/redis/internal"
)

var _ = Describe("Commands", func() {
Expand Down Expand Up @@ -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"}))
})

})

})
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4598ed0

Please sign in to comment.