Skip to content

Commit

Permalink
pubsub: Return integers for NUMSUB, not strings
Browse files Browse the repository at this point in the history
Also adds test for numsub — due to tcl being tcl,
it doesn't capture the "numberness" of the fix,
but now we at least have one test case for numsub.

Closes #1561
  • Loading branch information
mattsta authored and antirez committed Aug 27, 2014
1 parent 60c7486 commit 09a3976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pubsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void pubsubCommand(redisClient *c) {
list *l = dictFetchValue(server.pubsub_channels,c->argv[j]);

addReplyBulk(c,c->argv[j]);
addReplyBulkLongLong(c,l ? listLength(l) : 0);
addReplyLongLong(c,l ? listLength(l) : 0);
}
} else if (!strcasecmp(c->argv[1]->ptr,"numpat") && c->argc == 2) {
/* PUBSUB NUMPAT */
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/pubsub.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ start_server {tags {"pubsub"}} {
$rd1 close
}

test "NUMSUB returns numbers, not strings (#1561)" {
r pubsub numsub abc def
} {abc 0 def 0}

test "Mix SUBSCRIBE and PSUBSCRIBE" {
set rd1 [redis_deferring_client]
assert_equal {1} [subscribe $rd1 {foo.bar}]
Expand Down

0 comments on commit 09a3976

Please sign in to comment.