bwlewis / rredis

R client for Redis
http://illposed.net/
93 stars 25 forks source link

redisHMSet applied charToRaw on character list #29

Closed suh4 closed 8 years ago

suh4 commented 9 years ago

instead of serialization, redisHMSet applied charToRaw on characters and lost information. for example

> letters
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
> redisHMSet("test", list(letters = letters))
[1] "OK"
Warning message:
In charToRaw(values[[j]]) :
  argument should be a character vector of length 1
all but the first element will be ignored
> redisHGet("test", "letters")
[1] "a"
> 

the problem is below line

    > redisHMSet
    function (key, values) 
    {
        a <- c(alist(), list(.raw("HMSET")), list(.raw(key)))
        fieldnames <- lapply(names(values), charToRaw)
        for (j in 1:length(values)) {
            a <- c(a, fieldnames[j])
<<<<   if (is.character(values[[j]])) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                a <- c(a, list(charToRaw(values[[j]])))
            else (a <- c(a, list(.cerealize(values[[j]]))))
        }
        do.call(".redisCmd", a)
    }

Is this work as design or an issue?

bwlewis commented 9 years ago

This is a bug, thanks for finding it. I'll work on a fix right away and look for similar problems elsewhere.

bwlewis commented 8 years ago

Sorry for the extreme latency. This issue opened a bit of a can of worms, but it should be resolved now. See Issue #33 for some things that might change in the future.

This should make its way to CRAN by late November.