aembke / fred.rs

An async Redis client for Rust.
Apache License 2.0
384 stars 62 forks source link

[Bug] Certain ranges are not accepted in BYSCORE zranges #250

Open bbeausej opened 4 months ago

bbeausej commented 4 months ago

Fred version - 9.0.3 Redis version - 6.2.4 Platform - linux / wsl Deployment type - centralized

Describe the bug

Trying to find all negative score numbers (0 inclusive) using fred using zremrangebyscore. Passing "-inf" as min and 0 as max causes an Invalid Argument error to be emitted.

To Reproduce Steps to reproduce the behavior:

fred.zrangebyscore(&key, "-inf", 0).await?;

Invalid Argument: Invalid range bound with BYSCORE sort

Submitting the same manually with redis works perfectly:


127.0.0.1:6379> zadd mykey -10 neg1
(integer) 1
127.0.0.1:6379> zadd mykey -2 neg2
(integer) 1
127.0.0.1:6379> zadd mykey 0 zero
(integer) 1
127.0.0.1:6379> zadd mykey 1 one
(integer) 1
127.0.0.1:6379> zadd mykey 3 three
(integer) 1
127.0.0.1:6379> zrangebyscore mykey -inf 0
1) "neg1"
2) "neg2"
3) "zero"

Seems range checking is preventing legitimate ranges from being used, unless I wrongly understood the API usage.

Thanks for this amazing crate!

-b
aembke commented 4 months ago

Hi @bbeausej, could you provide a full rust code sample that reproduces this? I tried adding a test for this (https://github.com/aembke/fred.rs/blob/feat/9.1.0/tests/integration/sorted_sets/mod.rs#L772-L800) but haven't been able to repro the issue.