Cannot pass boolean from ruby to lua using hiredis.

Recently while looking through a redis db I discovered that it had a lot of empty string values. It turns out that using hiredis, you cannot pass a nil / false value from ruby to lua scripts. Some code was expecting a nil variable in ruby to evaluate to false in the lua script. However the hiredis extension converts everything to strings and therefore the nil value gets converted to an empty string.


for the internal details.

A have a quick irb session confirms the same:

  1. irb(main):001:0> nil.to_s
    => ""

See for a more detailed script.

Gotta be careful with such stuff. 

No comments:

Post a Comment