From 405011b64031639c19913d14b690b92ba03d209c Mon Sep 17 00:00:00 2001 From: DTrejo Date: Sat, 23 Feb 2013 22:56:08 -0500 Subject: [PATCH] Revert "hmset throws/errors out on non-string values. fixes #218" Reverting because this was a documentation problem, not a problem with the code. Performance-wise, this is faster than the approach in #345, though it may cause users more trouble. This is okay, if someone opens an issue we can point them to the docs. This reverts commit b60e001fa08403240a6ecbf0c36d1c08ed8ccd9d. Conflicts: index.js test.js --- README.md | 2 +- index.js | 8 -------- test.js | 18 ------------------ 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/README.md b/README.md index aab10658a2..82fed0b080 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ Output: Multiple values in a hash can be set by supplying an object: client.HMSET(key2, { - "0123456789": "abcdefghij", // NOTE: the key and value must both be strings + "0123456789": "abcdefghij", // NOTE: key and value will be coerced to strings "some manner of key": "a type of value" }); diff --git a/index.js b/index.js index bb224a5d31..4135dc1ec9 100644 --- a/index.js +++ b/index.js @@ -957,14 +957,6 @@ RedisClient.prototype.hmset = function (args, callback) { for (i = 0, il = tmp_keys.length; i < il ; i++) { key = tmp_keys[i]; tmp_args.push(key); - if (typeof args[1][key] !== "string") { - var err = new Error("hmset expected value to be a string", key, ":", args[1][key]); - if (callback) { - return callback(err); - } else { - throw err; - } - } tmp_args.push(args[1][key]); } args = tmp_args; diff --git a/test.js b/test.js index 1bdc4502e8..05a09ef6c1 100644 --- a/test.js +++ b/test.js @@ -1616,24 +1616,6 @@ tests.OPTIONAL_CALLBACK_UNDEFINED = function () { client.get("op_cb2", last(name, require_string("y", name))); }; -tests.HMSET_THROWS_ON_NON_STRINGS = function () { - var name = "HMSET_THROWS_ON_NON_STRINGS"; - var hash = name; - var data = { "a": [ "this is not a string" ] }; - - client.hmset(hash, data, cb); - function cb(e, r) { - assert(e); // should be an error! - } - - // alternative way it throws - function thrower() { - client.hmset(hash, data); - } - assert.throws(thrower); - next(name); -}; - tests.ENABLE_OFFLINE_QUEUE_TRUE = function () { var name = "ENABLE_OFFLINE_QUEUE_TRUE"; var cli = redis.createClient(9999, null, {