diff --git a/index.js b/index.js index b6038b3882..71c2553a96 100644 --- a/index.js +++ b/index.js @@ -412,6 +412,16 @@ RedisClient.prototype.return_reply = function (reply_buffer) { var command_obj = this.command_queue.shift(); if (command_obj && typeof command_obj.callback === "function") { + // HGETALL special case replies with keyed Buffers + if ('HGETALL' == command_obj.command) { + var obj = {}; + for (var i = 0, len = reply_buffer.length; i < len; ++i) { + var key = reply_buffer[i].toString(), + val = reply_buffer[++i]; + obj[key] = val; + } + reply_buffer = obj; + } command_obj.callback(null, reply_buffer); } else { if (this.debug_mode) { diff --git a/test.js b/test.js index d744fe244c..505fca0230 100644 --- a/test.js +++ b/test.js @@ -355,7 +355,7 @@ tests.HGETALL = function () { client.hmset(["hosts", "mjr", "1", "another", "23", "home", "1234"], require_string("OK", name)); client.HGETALL(["hosts"], function (err, obj) { assert.strictEqual(null, err, name + " result sent back unexpected error"); - assert.strictEqual(6, Object.keys(obj).length, name); + assert.strictEqual(3, Object.keys(obj).length, name); assert.ok(Buffer.isBuffer(obj.mjr), name); assert.strictEqual("1", obj.mjr.toString(), name); assert.strictEqual("23", obj.another.toString(), name);