diff --git a/pkg/redisdump/redisdump.go b/pkg/redisdump/redisdump.go index d889342..bb5ef85 100644 --- a/pkg/redisdump/redisdump.go +++ b/pkg/redisdump/redisdump.go @@ -127,7 +127,7 @@ func RedisCmdSerializer(cmd []string) string { buf := strings.Builder{} buf.WriteString(fmt.Sprintf("%s", cmd[0])) for i := 1; i < len(cmd); i++ { - if strings.Contains(cmd[i], " ") { + if strings.Contains(cmd[i], " ") || len(cmd[i]) == 0 { buf.WriteString(fmt.Sprintf(" \"%s\"", cmd[i])) } else { buf.WriteString(fmt.Sprintf(" %s", cmd[i])) diff --git a/pkg/redisdump/redisdump_test.go b/pkg/redisdump/redisdump_test.go index 1300fc3..64b1da5 100644 --- a/pkg/redisdump/redisdump_test.go +++ b/pkg/redisdump/redisdump_test.go @@ -214,6 +214,7 @@ func TestRedisCmdSerializer(t *testing.T) { {command: []string{"HELLO"}, expected: "HELLO"}, {command: []string{"HGETALL", "key"}, expected: "HGETALL key"}, {command: []string{"SET", "key name 1", "key value 1"}, expected: "SET \"key name 1\" \"key value 1\""}, + {command: []string{"SET", "key", ""}, expected: "SET key \"\""}, {command: []string{"HSET", "key1", "key value 1"}, expected: "HSET key1 \"key value 1\""}, }