]> git.saurik.com Git - redis.git/commitdiff
Return error to client on wrong type for HMGET
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 26 Oct 2010 10:26:27 +0000 (12:26 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 26 Oct 2010 10:33:17 +0000 (12:33 +0200)
src/t_hash.c
tests/unit/type/hash.tcl

index 5cef1cabbcd86addfd6133fcbd2c6261e2750ae5..071b7754a708c2aae9bc0a66982b7f2f7d9c6b1a 100644 (file)
@@ -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
index 2c0bd53492d0c4a83f2727af778a1e38c56fec28..8559dc3c3801c4a21513906318edf9141103b930 100644 (file)
@@ -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 {}