reddit / devvit

Reddit for Developers
https://developers.reddit.com
BSD 3-Clause "New" or "Revised" License
63 stars 14 forks source link

Redis zRange by lex does not behave like docs suggest` #93

Closed devvit-help-bot[bot] closed 6 days ago

devvit-help-bot[bot] commented 3 weeks ago

Details

Example gist: https://gist.github.com/fsvreddit/382476dcf4f1efe470dfb146a93a7e4d

by: lex appears to be taking the input as-is and prepending a [ to start/end unless the value is one of the special values - or +.

I should be able to work around this behaviour by deliberately manipulating the strings I put in.

Additional info

Discord message: _I don't think that zRange by lex is working quite like the official Redis documentation says it should. Imagine a sorted set with members a, b, c, d and e.

const res = await context.redis.zRange("myKey", "[b", "[d", { by: "lex" }); should return ["b", "c", "d"] because the [ indicates an inclusive range, and const res = await context.redis.zRange("myKey", "(b", "(e", { by: "lex" }); should return just ["c"] because ( indicates exclusive. However in both cases I just get an empty array.

If I omit the ( or [, I get b, c and d however. This implies to me some processing is happening on the server rather than the inputs being taken as-is._

Message author: big.wheel

Discord link: https://discord.com/channels/1050224141732687912/1242689538447507458/1287404638345367612

shannon-feng commented 6 days ago

I made a few updates that allow devs to prepend the start/stop input with ( or [. If the input doesn't have ( or [ in front of it, then the server will prepend an inclusive bracket [ by default.

additionally, you can pass in - or + as input to indicate negative or positive infinity strings.

Developer docs have been updated to reflect the changes.