seomoz/qless — pull request #73 by databus23 (2013-01-24 15:18:21+00:00)
Title: empty arrays in job data are not properly (de)serialized

I just run across a glitch with qless that empty arrays in job data are not properly serialized and deserialized in less. They wind up as an empty objects when fetching the jobs data from redis.

Thats because lua knows only tables and has no way of distinguishing between an empty object and and empty array:

redis> EVAL 'return cjson.encode(cjson.decode(\'[]\'))' 0
"{}"

Definitely not a big issue but I don't really like the limitation caused by the in principle unnecessary decoding and encoding of the job data via `cjson` as qless does nothing with the job specific data.

I tried to fix this by saving the raw unprocessed JSON to redis in the `put.lua` script which is straight forward. Then I noticed that its a little more difficult to have the `get.lua` script also pass back the unprocessed JSON as the script's result is wrapped in a big `cjson.encode(...)`.

Attached is a simple failing spec for the issue.

What do think? Is this worth tackling or do we need to live with it as a limitation of the lua interpreter?