forked from mirror/ledisdb
fix bug - unify the return score type to bluk while call rangeXXX
This commit is contained in:
parent
dee78beef1
commit
d0e15d4c1d
|
@ -77,7 +77,7 @@ func TestDBZSet(t *testing.T) {
|
|||
t.Fatal(s)
|
||||
}
|
||||
|
||||
if s, err := db.ZScore(key, bin("zzz")); err != errScoreMiss || s != InvalidScore {
|
||||
if s, err := db.ZScore(key, bin("zzz")); err != ErrScoreMiss || s != InvalidScore {
|
||||
t.Fatal(fmt.Sprintf("s=[%d] err=[%s]", s, err))
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ func zincrbyCommand(c *client) error {
|
|||
if v, err := c.db.ZIncrBy(key, delta, args[2]); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.writeBulk(v)
|
||||
c.writeBulk(ledis.StrPutInt64(v))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -312,10 +312,16 @@ func zrangeGeneric(c *client, reverse bool) error {
|
|||
withScores = true
|
||||
}
|
||||
|
||||
if v, err := c.db.ZRangeGeneric(key, start, stop, withScores, reverse); err != nil {
|
||||
if datas, err := c.db.ZRangeGeneric(key, start, stop, withScores, reverse); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.writeArray(v)
|
||||
if withScores {
|
||||
for i := len(datas) - 1; i > 0; i -= 2 {
|
||||
v, _ := datas[i].(int64)
|
||||
datas[i] = ledis.StrPutInt64(v)
|
||||
}
|
||||
}
|
||||
c.writeArray(datas)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -377,10 +383,16 @@ func zrangebyscoreGeneric(c *client, reverse bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if v, err := c.db.ZRangeByScoreGeneric(key, min, max, withScores, offset, count, reverse); err != nil {
|
||||
if datas, err := c.db.ZRangeByScoreGeneric(key, min, max, withScores, offset, count, reverse); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.writeArray(v)
|
||||
if withScores {
|
||||
for i := len(datas) - 1; i > 0; i -= 2 {
|
||||
v, _ := datas[i].(int64)
|
||||
datas[i] = ledis.StrPutInt64(v)
|
||||
}
|
||||
}
|
||||
c.writeArray(datas)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue