You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Fix small issues with hmset & multi constructor
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
## v2.x.x - xx, 2015
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
|
||||||
|
- Fix argument mutation while using the array notation with the multi constructor (@BridgeAR)
|
||||||
|
- Fix multi.hmset key not being type converted if used with an object and key not being a string (@BridgeAR)
|
||||||
|
|
||||||
## v2.0.1 - Sep 24, 2015
|
## v2.0.1 - Sep 24, 2015
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
||||||
- Fix argument mutation while using the array notation in combination with keys / callbacks ([#866]). (@BridgeAR)
|
- Fix argument mutation while using the array notation in combination with keys / callbacks ([#866](.)). (@BridgeAR)
|
||||||
|
|
||||||
## v2.0.0 - Sep 21, 2015
|
## v2.0.0 - Sep 21, 2015
|
||||||
|
|
||||||
|
5
index.js
5
index.js
@@ -860,7 +860,8 @@ function Multi(client, args) {
|
|||||||
var command, tmp_args;
|
var command, tmp_args;
|
||||||
if (Array.isArray(args)) {
|
if (Array.isArray(args)) {
|
||||||
while (tmp_args = args.shift()) {
|
while (tmp_args = args.shift()) {
|
||||||
command = tmp_args.shift();
|
command = tmp_args[0];
|
||||||
|
tmp_args = tmp_args.slice(1);
|
||||||
if (Array.isArray(command)) {
|
if (Array.isArray(command)) {
|
||||||
this[command[0]].apply(this, command.slice(1).concat(tmp_args));
|
this[command[0]].apply(this, command.slice(1).concat(tmp_args));
|
||||||
} else {
|
} else {
|
||||||
@@ -989,10 +990,10 @@ Multi.prototype.hmset = Multi.prototype.HMSET = function (key, args, callback) {
|
|||||||
}
|
}
|
||||||
tmp_args = ['hmset', key].concat(args);
|
tmp_args = ['hmset', key].concat(args);
|
||||||
} else if (typeof args === "object") {
|
} else if (typeof args === "object") {
|
||||||
tmp_args = ["hmset", key];
|
|
||||||
if (typeof key !== "string") {
|
if (typeof key !== "string") {
|
||||||
key = key.toString();
|
key = key.toString();
|
||||||
}
|
}
|
||||||
|
tmp_args = ["hmset", key];
|
||||||
var fields = Object.keys(args);
|
var fields = Object.keys(args);
|
||||||
while (field = fields.shift()) {
|
while (field = fields.shift()) {
|
||||||
tmp_args.push(field);
|
tmp_args.push(field);
|
||||||
|
@@ -151,8 +151,9 @@ describe("The 'multi' method", function () {
|
|||||||
var arr = ["multihmset", "multibar", "multibaz"];
|
var arr = ["multihmset", "multibar", "multibaz"];
|
||||||
var arr2 = ['some manner of key', 'otherTypes'];
|
var arr2 = ['some manner of key', 'otherTypes'];
|
||||||
var arr3 = [5768, "multibarx", "multifoox"];
|
var arr3 = [5768, "multibarx", "multifoox"];
|
||||||
|
var arr4 = ["mset", [578, "multibar"], helper.isString('OK')];
|
||||||
client.multi([
|
client.multi([
|
||||||
["mset", [578, "multibar"], helper.isString('OK')],
|
arr4,
|
||||||
[["mset", "multifoo2", "multibar2", "multifoo3", "multibar3"], helper.isString('OK')],
|
[["mset", "multifoo2", "multibar2", "multifoo3", "multibar3"], helper.isString('OK')],
|
||||||
["hmset", arr],
|
["hmset", arr],
|
||||||
[["hmset", "multihmset2", "multibar2", "multifoo3", "multibar3", "test", helper.isString('OK')]],
|
[["hmset", "multihmset2", "multibar2", "multifoo3", "multibar3", "test", helper.isString('OK')]],
|
||||||
@@ -160,7 +161,7 @@ describe("The 'multi' method", function () {
|
|||||||
["hmset", arr3, helper.isString('OK')],
|
["hmset", arr3, helper.isString('OK')],
|
||||||
['hmset', now, {123456789: "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}],
|
['hmset', now, {123456789: "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}],
|
||||||
['hmset', 'key2', {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 999}, helper.isString('OK')],
|
['hmset', 'key2', {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 999}, helper.isString('OK')],
|
||||||
["hmset", "multihmset", ["multibar", "multibaz"]],
|
["HMSET", "multihmset", ["multibar", "multibaz"]],
|
||||||
["hmset", "multihmset", ["multibar", "multibaz"], helper.isString('OK')],
|
["hmset", "multihmset", ["multibar", "multibaz"], helper.isString('OK')],
|
||||||
])
|
])
|
||||||
.hmget(now, 123456789, 'otherTypes')
|
.hmget(now, 123456789, 'otherTypes')
|
||||||
@@ -174,6 +175,7 @@ describe("The 'multi' method", function () {
|
|||||||
assert.equal(arr.length, 3);
|
assert.equal(arr.length, 3);
|
||||||
assert.equal(arr2.length, 2);
|
assert.equal(arr2.length, 2);
|
||||||
assert.equal(arr3.length, 3);
|
assert.equal(arr3.length, 3);
|
||||||
|
assert.equal(arr4.length, 3);
|
||||||
assert.strictEqual(null, err);
|
assert.strictEqual(null, err);
|
||||||
assert.equal(replies[10][1], '555');
|
assert.equal(replies[10][1], '555');
|
||||||
assert.equal(replies[11][0], 'a type of value');
|
assert.equal(replies[11][0], 'a type of value');
|
||||||
@@ -186,6 +188,14 @@ describe("The 'multi' method", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('converts a non string key to a string', function(done) {
|
||||||
|
// TODO: Converting the key might change soon again.
|
||||||
|
client.multi().hmset(true, {
|
||||||
|
test: 123,
|
||||||
|
bar: 'baz'
|
||||||
|
}).exec(done);
|
||||||
|
});
|
||||||
|
|
||||||
it('allows multiple operations to be performed using a chaining API', function (done) {
|
it('allows multiple operations to be performed using a chaining API', function (done) {
|
||||||
client.multi()
|
client.multi()
|
||||||
.mset('some', '10', 'keys', '20')
|
.mset('some', '10', 'keys', '20')
|
||||||
|
Reference in New Issue
Block a user