sds / mock_redis

Mock Redis gem for Ruby
Other
493 stars 157 forks source link

[Bug] `MockRedis#hset` behavior differs from `Redis#hset` when passing flattened array #310

Closed iwaseasahi closed 1 week ago

iwaseasahi commented 1 week ago

Versions

Description

There is a difference in behavior between MockRedis#hset and Redis#hset when passing a flattened array.

With Redis:

require 'redis'
redis = Redis.new

hash = {:name=>"job", :namespace=>"default", :klass=>"Job"}
redis.hset("key", hash.flatten)

redis.hgetall("key")
=> {"name"=>"job", "namespace"=>"default", "klass"=>"Job"}

With MockRedis:

require 'mock_redis'
mock_redis = MockRedis.new

hash = {:name=>"job", :namespace=>"default", :klass=>"Job"}
mock_redis.hset("key", hash.flatten)

mock_redis.hgetall("key")
=> {"[:name, \"job\", :namespace, \"default\", :klass, \"Job\"]"=>""}
jvanderen1 commented 1 week ago

Opened https://github.com/sds/mock_redis/pull/312 to resolve this issue.

iwaseasahi commented 1 week ago

@jvanderen1 Thank you very much!