fix to return error when calling INCR on a non-string type

This commit is contained in:
Pieter Noordhuis 2010-05-11 22:46:24 +02:00
parent 1b67773229
commit 6485f29382
2 changed files with 3 additions and 3 deletions

View File

@ -4231,8 +4231,8 @@ static void incrDecrCommand(redisClient *c, long long incr) {
robj *o;
o = lookupKeyWrite(c->db,c->argv[1]);
if (getLongLongFromObjectOrReply(c, o, &value, NULL) != REDIS_OK) return;
if (o != NULL && checkType(c,o,REDIS_STRING)) return;
if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;
value += incr;
o = createObject(REDIS_STRING,sdscatprintf(sdsempty(),"%lld",value));

View File

@ -373,7 +373,7 @@ proc main {} {
test {INCR fails against a key holding a list} {
$r rpush mylist 1
catch {$r incr novar} err
catch {$r incr mylist} err
$r rpop mylist
format $err
} {ERR*}