Skip to content
Browse files

Return error to client on wrong type for HMGET

  • Loading branch information...
1 parent 244201f commit e584d82fecd13afa8de5e9c129789da6a70117d9 @pietern pietern committed
Showing with 6 additions and 0 deletions.
  1. +1 −0 src/t_hash.c
  2. +5 −0 tests/unit/type/hash.tcl
View
1 src/t_hash.c
@@ -310,6 +310,7 @@ void hmgetCommand(redisClient *c) {
o = lookupKeyRead(c->db,c->argv[1]);
if (o != NULL && o->type != REDIS_HASH) {
addReply(c,shared.wrongtypeerr);
+ return;
}
/* Note the check for o != NULL happens inside the loop. This is
View
5 tests/unit/type/hash.tcl
@@ -140,6 +140,11 @@ start_server {tags {"hash"}} {
set _ $rv
} {{{} {}} {{} {}} {{} {}}}
+ test {HMGET against wrong type} {
+ r set wrongtype somevalue
+ assert_error "*wrong*" {r hmget wrongtype field1 field2}
+ }
+
test {HMGET - small hash} {
set keys {}
set vals {}

0 comments on commit e584d82

Please sign in to comment.
Something went wrong with that request. Please try again.