diff options
author | Binbin <binloveplay1314@qq.com> | 2021-07-05 15:41:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 10:41:57 +0300 |
commit | a418a2d3fc0250c094802d7e8ea64d96eedfda07 (patch) | |
tree | 045a120fc63b592d54a00e966cdf05d4e291b260 /src/t_zset.c | |
parent | 5a3de81925130792f78c35e9e4d0204213a3a41e (diff) | |
download | redis-a418a2d3fc0250c094802d7e8ea64d96eedfda07.tar.gz |
hrandfield and zrandmember with count should return emptyarray when key does not exist. (#9178)
due to a copy-paste bug, it used to reply with null response rather than empty array.
this commit includes new tests that are looking at the RESP response directly in
order to be able to tell the difference between them.
Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/t_zset.c')
-rw-r--r-- | src/t_zset.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index 51a14989d..28f1df05e 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -4000,7 +4000,7 @@ void zrandmemberWithCountCommand(client *c, long l, int withscores) { int uniq = 1; robj *zsetobj; - if ((zsetobj = lookupKeyReadOrReply(c, c->argv[1], shared.null[c->resp])) + if ((zsetobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptyarray)) == NULL || checkType(c, zsetobj, OBJ_ZSET)) return; size = zsetLength(zsetobj); @@ -4188,7 +4188,7 @@ void zrandmemberWithCountCommand(client *c, long l, int withscores) { zuiClearIterator(&src); } -/* ZRANDMEMBER [<count> WITHSCORES] */ +/* ZRANDMEMBER key [<count> [WITHSCORES]] */ void zrandmemberCommand(client *c) { long l; int withscores = 0; |