mirror of
https://github.com/redis/go-redis.git
synced 2025-07-23 21:01:00 +03:00
fix: Fix panic caused when arg is nil (#3353)
This commit is contained in:
@ -81,6 +81,8 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
|
|||||||
return dst
|
return dst
|
||||||
case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
|
case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
|
||||||
return append(dst, arg)
|
return append(dst, arg)
|
||||||
|
case nil:
|
||||||
|
return dst
|
||||||
default:
|
default:
|
||||||
// scan struct field
|
// scan struct field
|
||||||
v := reflect.ValueOf(arg)
|
v := reflect.ValueOf(arg)
|
||||||
|
@ -7209,6 +7209,17 @@ var _ = Describe("Commands", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("returns empty values when args are nil", func() {
|
||||||
|
vals, err := client.Eval(
|
||||||
|
ctx,
|
||||||
|
"return {ARGV[1]}",
|
||||||
|
[]string{},
|
||||||
|
nil,
|
||||||
|
).Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(vals).To(BeEmpty())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("EvalRO", func() {
|
Describe("EvalRO", func() {
|
||||||
@ -7232,6 +7243,17 @@ var _ = Describe("Commands", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("returns empty values when args are nil", func() {
|
||||||
|
vals, err := client.EvalRO(
|
||||||
|
ctx,
|
||||||
|
"return {ARGV[1]}",
|
||||||
|
[]string{},
|
||||||
|
nil,
|
||||||
|
).Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(vals).To(BeEmpty())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Functions", func() {
|
Describe("Functions", func() {
|
||||||
|
Reference in New Issue
Block a user