mirror of https://github.com/go-redis/redis.git
Don't create empty map when value is missing
This commit is contained in:
parent
a8704c3bd0
commit
4eb2debcdc
16
command.go
16
command.go
|
@ -1003,18 +1003,20 @@ func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := rd.ReadArrayReply(stringInterfaceMapParser)
|
var values map[string]interface{}
|
||||||
if err != nil && err != proto.Nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if v == nil || err == proto.Nil {
|
v, err := rd.ReadArrayReply(stringInterfaceMapParser)
|
||||||
v = make(map[string]interface{})
|
if err != nil {
|
||||||
|
if err != proto.Nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
values = v.(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
msgs[i] = XMessage{
|
msgs[i] = XMessage{
|
||||||
ID: id,
|
ID: id,
|
||||||
Values: v.(map[string]interface{}),
|
Values: values,
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -3638,7 +3638,7 @@ var _ = Describe("Commands", func() {
|
||||||
Stream: "stream",
|
Stream: "stream",
|
||||||
Messages: []redis.XMessage{
|
Messages: []redis.XMessage{
|
||||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||||
{ID: "2-0", Values: map[string]interface{}{}},
|
{ID: "2-0", Values: nil},
|
||||||
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
|
||||||
}},
|
}},
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue