mranney/node_redis — Issue #182: Space-delimited commands are not handled by send_command()
Author: thauburger
Created: 2012-03-04 13:01:12+00:00
State: open

This morning, I attempted to use `send_command()` to execute`DEBUG OBJECT` on a Redis key. This resulted in the error: " ERR unknown command 'debug object' ".

`DEBUG OBJECT` is one of the commands listed in `lib/commands.js`, and is successfully added to the RedisClient prototype object during initialization.

However, neither method of invocation seemed to be working:

* `client['DEBUG OBJECT']()`
* `client.send_command('DEBUG OBJECT' .... )`

Since `send_command()` issues all commands in the multi-bulk format, I started examining the construction of the raw format strings.

If we take the `DEBUG OBJECT` example:

The existing approach bundled the command as a single element in the multi-bulk request:

````
*2
$12
DEBUG OBJECT
$7
testkey

````
Unfortunately, it appears as though Redis rejects this format.

[I've submitted a patch for `send_command()` in pull request #181](https://github.com/mranney/node_redis/pull/181).

The patched approach first parses the command string for multiple words, and then gives each word its own element in the multi-bulk request:

````
*3
$5
DEBUG
$6
OBJECT
$7
testkey
````
This appears to be fully functional for me.

By my count, there are currently 5 commands in Redis which are space-delimited:

* `CONFIG GET`
* `CONFIG SET`
* `CONFIG RESETSTAT`
* `DEBUG OBJECT`
* `DEBUG SEGFAULT`

My understanding is that `send_command()` is designed to mirror redis-cli functionality from within a node process. This patch helps provide more complete command support (which I believe is now at 100%).

Thanks!