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_hash.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_hash.c')
-rw-r--r-- | src/t_hash.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/t_hash.c b/src/t_hash.c index 865145807..7a1215b13 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -989,7 +989,7 @@ void hrandfieldWithCountCommand(client *c, long l, int withvalues) { int uniq = 1; robj *hash; - if ((hash = lookupKeyReadOrReply(c,c->argv[1],shared.null[c->resp])) + if ((hash = lookupKeyReadOrReply(c,c->argv[1],shared.emptyarray)) == NULL || checkType(c,hash,OBJ_HASH)) return; size = hashTypeLength(hash); @@ -1178,7 +1178,7 @@ void hrandfieldWithCountCommand(client *c, long l, int withvalues) { } } -/* HRANDFIELD [<count> WITHVALUES] */ +/* HRANDFIELD key [<count> [WITHVALUES]] */ void hrandfieldCommand(client *c) { long l; int withvalues = 0; |