Skip to content

SortedSetRangeByValue not handling null values #992

@srulandhs

Description

@srulandhs

I'm attempting to use a Redis SortedSet in lexical compare mode. I am unable to get the StackExchange.Redis library to behave the same as when I issue the commands directly thur the redis console.

Versions
Redis: 4.0.0 via docker
Redis Desktop Mgr: 0.9.5
StackExchange.Redis: 2.0.513

Seed data
SortedSetAdd("testkey", "a:1000", 0, When.NotExists);
SortedSetAdd("testkey", "b:2000", 0, When.NotExists);
SortedSetAdd("testkey", "c:3000", 0, When.NotExists);
SortedSetAdd("testkey", "d:4000", 0, When.NotExists);
SortedSetAdd("testkey", "e:5000", 0, When.NotExists);
SortedSetAdd("testkey", "f:6000", 0, When.NotExists);

SortedSetRangeByValue("testkey", "a", RedisValue.Null)
yields: no matches

however
zrangebylex testkey [a +
yields
a:1000
b:2000
c:3000
d:0000
e:5000
f:6000

In looking through the code, I think that the issue may be in ReverseLimits()
The first line issues a start.CompareTo(stop). The null RedisValue seem to return true here which causes the min and max to be swapped.
Due to this swap it seems that the following is being executed:
zrangebylex testkey - [a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions