Skip to content
This repository
Browse code

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 b60e001.

Conflicts:

	index.js
	test.js
  • Loading branch information...
commit 405011b64031639c19913d14b690b92ba03d209c 1 parent a02b0f5
David Trejo authored February 23, 2013
2  README.md
Source Rendered
@@ -282,7 +282,7 @@ Output:
282 282
 Multiple values in a hash can be set by supplying an object:
283 283
 
284 284
     client.HMSET(key2, {
285  
-        "0123456789": "abcdefghij", // NOTE: the key and value must both be strings
  285
+        "0123456789": "abcdefghij", // NOTE: key and value will be coerced to strings
286 286
         "some manner of key": "a type of value"
287 287
     });
288 288
 
8  index.js
@@ -957,14 +957,6 @@ RedisClient.prototype.hmset = function (args, callback) {
957 957
         for (i = 0, il = tmp_keys.length; i < il ; i++) {
958 958
             key = tmp_keys[i];
959 959
             tmp_args.push(key);
960  
-            if (typeof args[1][key] !== "string") {
961  
-                var err = new Error("hmset expected value to be a string", key, ":", args[1][key]);
962  
-                if (callback) {
963  
-                    return callback(err);
964  
-                } else {
965  
-                    throw err;
966  
-                }
967  
-            }
968 960
             tmp_args.push(args[1][key]);
969 961
         }
970 962
         args = tmp_args;
18  test.js
@@ -1616,24 +1616,6 @@ tests.OPTIONAL_CALLBACK_UNDEFINED = function () {
1616 1616
     client.get("op_cb2", last(name, require_string("y", name)));
1617 1617
 };
1618 1618
 
1619  
-tests.HMSET_THROWS_ON_NON_STRINGS = function () {
1620  
-    var name = "HMSET_THROWS_ON_NON_STRINGS";
1621  
-    var hash = name;
1622  
-    var data = { "a": [ "this is not a string" ] };
1623  
-
1624  
-    client.hmset(hash, data, cb);
1625  
-    function cb(e, r) {
1626  
-        assert(e); // should be an error!
1627  
-    }
1628  
-
1629  
-    // alternative way it throws
1630  
-    function thrower() {
1631  
-        client.hmset(hash, data);
1632  
-    }
1633  
-    assert.throws(thrower);
1634  
-    next(name);
1635  
-};
1636  
-
1637 1619
 tests.ENABLE_OFFLINE_QUEUE_TRUE = function () {
1638 1620
     var name = "ENABLE_OFFLINE_QUEUE_TRUE";
1639 1621
     var cli = redis.createClient(9999, null, {

0 notes on commit 405011b

Please sign in to comment.
Something went wrong with that request. Please try again.