forked from mirror/ledisdb
bugfix for revrangebyscore command
min and max score param position may be same as redis
This commit is contained in:
parent
d5cd9e10eb
commit
1e6bcc6a50
|
@ -335,7 +335,17 @@ func zrangebyscoreGeneric(c *client, reverse bool) error {
|
|||
}
|
||||
|
||||
key := args[0]
|
||||
min, max, err := zparseScoreRange(args[1], args[2])
|
||||
|
||||
var minScore, maxScore []byte
|
||||
|
||||
if !reverse {
|
||||
minScore, maxScore = args[1], args[2]
|
||||
} else {
|
||||
minScore, maxScore = args[2], args[1]
|
||||
}
|
||||
|
||||
min, max, err := zparseScoreRange(minScore, maxScore)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ func TestZSetRangeScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, 1, 4, "withscores")); err != nil {
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, 4, 1, "withscores")); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if err := testZSetRange(v, "d", 4, "c", 3, "b", 2, "a", 1); err != nil {
|
||||
|
@ -272,7 +272,7 @@ func TestZSetRangeScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, 1, 4, "withscores", "limit", 1, 2)); err != nil {
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, 4, 1, "withscores", "limit", 1, 2)); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if err := testZSetRange(v, "c", 3, "b", 2); err != nil {
|
||||
|
@ -280,7 +280,7 @@ func TestZSetRangeScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, "-inf", "+inf", "withscores")); err != nil {
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, "+inf", "-inf", "withscores")); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if err := testZSetRange(v, "d", 4, "c", 3, "b", 2, "a", 1); err != nil {
|
||||
|
@ -288,7 +288,7 @@ func TestZSetRangeScore(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, "(1", "(4")); err != nil {
|
||||
if v, err := ledis.MultiBulk(c.Do("zrevrangebyscore", key, "(4", "(1")); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if err := testZSetRange(v, "c", "b"); err != nil {
|
||||
|
|
Loading…
Reference in New Issue