nalgeon / redka

Redis re-implemented with SQLite
BSD 3-Clause "New" or "Revised" License
3.45k stars 94 forks source link

ZRANGE seems to have bug that not work with range 0 -1 #27

Closed Jianghong-bgcg closed 3 months ago

Jianghong-bgcg commented 3 months ago

I'm using the 0.5 ver of redka, and when I play around with redis official doc, it seems ZRANGE key 0 -1 doesn't work:

root@US06-199W-74732:redka# redis-cli
127.0.0.1:6379> keys "*"
1) "racer_scores"
127.0.0.1:6379> type racer_scores
zset
127.0.0.1:6379> ZRANGE racer_scores 0 -1
(empty array)
127.0.0.1:6379> ZRANGE racer_scores 0 -1 WITHSCORES
Error: Server closed the connection
127.0.0.1:6379> ZRANGEBYSCORE racer_scores -inf 10
Could not connect to Redis at 127.0.0.1:6379: Connection refused

Redka kills itself afterwards.
However if I run the ZRANGEBYSCORE command it does have value, meaning it's not my input that's corrupt

127.0.0.1:6379> ZRANGEBYSCORE racer_scores -inf 10
1) "Ford"
2) "Sam-Bodden"
3) "Norem"
4) "Royce"
nalgeon commented 3 months ago

zrange in Redka does not support negative start and stop parameters when ranging by rank, so this is the expected result:

> zrange racer_scores 0 -1
(empty array)

> zrange racer_scores 0 -1 withscores
(empty array)

Crashing on WITHSCORES is a bug, I'll fix it.