ioredis-mock icon indicating copy to clipboard operation
ioredis-mock copied to clipboard

Commands that return arrays use zero-based indexing when executed within lua scripts

Open jayalfredprufrock opened this issue 6 years ago • 1 comments

Super excited to see support for lua scripts which was the one thing preventing me from using this library in my unit tests! Many thanks to @nbarrera and @stipsan for all the work on that front.

While integrating, I've got a few tests failing (that pass when using an actual ioredis connection) and I think I tracked it down to commands that have an array response (i.e. zrange). It seems that the table/array returned from such commands uses zero-based indexing instead of the expected 1-based indexing.

Here is a small test case to show what I'm talking about https://runkit.com/embed/orgqbiq0910j

It wasn't immediately clear to me where/how to fix this or I would just submit a PR.

jayalfredprufrock avatar Feb 16 '19 03:02 jayalfredprufrock

Hey! It turns out the problem got flipped after we released

image

in v4.13.1.

I'll circle back later and check this out if nobody else can meanwhile 😃

stipsan avatar Jul 30 '19 14:07 stipsan