redis-rb/redis-client

[Major] Command Builder has an error for Nested array, TrueClass, FalseClass

gtv-thiennguyen opened this issue · 1 comments

File path: lib/redis_client/command_builder.rb:27

Given an array: [[1, 2, 3], [4, 5, 6], [[7, 8, 9]], true, false]

I can see that this block cannot solve the given input above.
The result is: it raises TypeError, "Unsupported command argument type: #{element.class}"

        command.map! do |element|
          case element
          when String
            element
          when Integer, Float
            element.to_s
          else
            raise TypeError, "Unsupported command argument type: #{element.class}"
          end
        end

My suggestion for this case is:

        command.map! do |element|
          case element
          when String
            element
          when Integer, Float
            element.to_s
          when TrueClass, FalseClass
            element.to_s
          when Array
            element.join(',')
          else
            raise TypeError, "Unsupported command argument type: #{element.class}"
          end
        end

I would appreciate if you can address this problem

This is on purpose. We only flatten one level.

You are free to change the default command builder for your own in your app, it's all configurable.