sds / mock_redis

Mock Redis gem for Ruby
Other
492 stars 154 forks source link

Unable to execute `#call` with redis command in `pipelined` #278

Closed viralpraxis closed 1 year ago

viralpraxis commented 1 year ago

Gem version: 0.37.0

Hi! I'm not sure if it was already mentioned in earlier issues. I observe that performing call inside pipeline raises an exception:

redis_client = MockRedis.new

results = redis_client.pipelined do |pipeline|
  pipeline.call(["expire", "foobar", 42])
end

results[0]
# => #<NoMethodError: undefined method `call' for #<MockRedis::Database:0x000055cbbadfa328>

Ordinary operations do work as expected:

redis_client.call(["set", "foobar", 42])
# => "OK"
redis_client.call(["expire", "foobar", 42])
# => true

And original redis-client (4.5.1) works as expected too:


redis_client.pipelined do |pipeline|
  pipeline.call(["set", "foobar", "val"])
  pipeline.call(["expire", "foobar", 1337])
  pipeline.call(["ttl", "foobar"])
end 

=begin
[
    [0] "OK",
    [1] 1,
    [2] 1337
]
=end

Could you please clarify it it's an unimplemented feature or a bug?

sds commented 1 year ago

Likely was never supported. Happy to merge a PR adding support!