]> git.saurik.com Git - redis.git/commitdiff
Now SORT returns an empty bulk reply if the key does not exist
authorantirez <antirez@gmail.com>
Fri, 18 Dec 2009 14:06:53 +0000 (09:06 -0500)
committerantirez <antirez@gmail.com>
Fri, 18 Dec 2009 14:06:53 +0000 (09:06 -0500)
redis.c
test-redis.tcl

diff --git a/redis.c b/redis.c
index 274dec7a85a3be63c984783ea27c73026fdf6716..91c28a0cebc1d7eb138d72d4563e8586eaf255e7 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -4839,7 +4839,7 @@ static void sortCommand(redisClient *c) {
     /* Lookup the key to sort. It must be of the right types */
     sortval = lookupKeyRead(c->db,c->argv[1]);
     if (sortval == NULL) {
     /* Lookup the key to sort. It must be of the right types */
     sortval = lookupKeyRead(c->db,c->argv[1]);
     if (sortval == NULL) {
-        addReply(c,shared.nokeyerr);
+        addReply(c,shared.nullmultibulk);
         return;
     }
     if (sortval->type != REDIS_SET && sortval->type != REDIS_LIST &&
         return;
     }
     if (sortval->type != REDIS_SET && sortval->type != REDIS_LIST &&
index 665d2bbff4060112954f59359970bdc803986aff..c5f15bfb5444b9f04735f83898271b62c2f02f84 100644 (file)
@@ -962,6 +962,10 @@ proc main {server port} {
         $r sort mylist BY weight_* GET #
     } {2 1 3}
 
         $r sort mylist BY weight_* GET #
     } {2 1 3}
 
+    test {SORT with constant GET} {
+        $r sort mylist GET foo
+    } {{} {} {}}
+
     test {LREM, remove all the occurrences} {
         $r flushdb
         $r rpush mylist foo
     test {LREM, remove all the occurrences} {
         $r flushdb
         $r rpush mylist foo