Skip to content

Commit

Permalink
Return error to client on wrong type for HMGET
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Oct 26, 2010
1 parent 244201f commit e584d82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/t_hash.c
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/type/hash.tcl
Expand Up @@ -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 {}
Expand Down

0 comments on commit e584d82

Please sign in to comment.