mirror of https://github.com/go-redis/redis.git
Correctly parse EVAL response containing customized error (#710)
* always parse all content in an array including error
This commit is contained in:
parent
daab7c60d0
commit
4598ed0eac
|
@ -10,6 +10,7 @@ import (
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
"github.com/go-redis/redis"
|
"github.com/go-redis/redis"
|
||||||
|
"github.com/go-redis/redis/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Commands", func() {
|
var _ = Describe("Commands", func() {
|
||||||
|
@ -2993,6 +2994,15 @@ var _ = Describe("Commands", func() {
|
||||||
Expect(vals).To(Equal([]interface{}{"key", "hello"}))
|
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"}))
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,7 +17,7 @@ func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
if err == Nil {
|
if err == Nil {
|
||||||
vals = append(vals, nil)
|
vals = append(vals, nil)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, err
|
vals = append(vals, err)
|
||||||
} else {
|
} else {
|
||||||
switch vv := v.(type) {
|
switch vv := v.(type) {
|
||||||
case []byte:
|
case []byte:
|
||||||
|
|
Loading…
Reference in New Issue