From bbd48a6facca78453a0c7ebe438a6f71ff79e563 Mon Sep 17 00:00:00 2001 From: Andy Ray Date: Fri, 28 Jan 2011 15:34:24 -0500 Subject: [PATCH] fix for issue of saving document with buffer AND array on it --- index.js | 2 +- test.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 77695ba391..9bd1eddba5 100644 --- a/index.js +++ b/index.js @@ -529,7 +529,7 @@ RedisClient.prototype.send_command = function () { for (i = 0, il = args.length, arg; i < il; i += 1) { arg = args[i]; - if (arg.length === undefined) { + if (!(arg instanceof Buffer || arg instanceof String)) { arg = String(arg); } diff --git a/test.js b/test.js index 70dec37a06..83192e44f5 100644 --- a/test.js +++ b/test.js @@ -285,6 +285,17 @@ tests.HSET = function () { client.HSET(key, field2, value2, last(name, require_number(0, name))); }; +tests.HMSET_BUFFER_AND_ARRAY = function () { + // Saving a buffer and an array to the same document should not error + var key = "test hash", + field1 = "buffer", + value1 = new Buffer("abcdefghij"), + field2 = "array", + value2 = [], + name = "HSET"; + + client.HMSET(key, field1, value1, field2, value2, last(name, require_string("OK", name))); +}; tests.HMGET = function () { var key1 = "test hash 1", key2 = "test hash 2", name = "HMGET";