1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Avoid collision between command and internal field

This commit is contained in:
Jonas Dohse
2013-03-14 15:40:32 +01:00
parent de22a94edd
commit 67e908ad55
2 changed files with 36 additions and 5 deletions

View File

@@ -841,7 +841,7 @@ RedisClient.prototype.end = function () {
}; };
function Multi(client, args) { function Multi(client, args) {
this.client = client; this._client = client;
this.queue = [["MULTI"]]; this.queue = [["MULTI"]];
if (Array.isArray(args)) { if (Array.isArray(args)) {
this.queue = this.queue.concat(args); this.queue = this.queue.concat(args);
@@ -1009,7 +1009,7 @@ Multi.prototype.exec = function (callback) {
args.push(obj[key]); args.push(obj[key]);
}); });
} }
this.client.send_command(command, args, function (err, reply) { this._client.send_command(command, args, function (err, reply) {
if (err) { if (err) {
var cur = self.queue[index]; var cur = self.queue[index];
if (typeof cur[cur.length - 1] === "function") { if (typeof cur[cur.length - 1] === "function") {
@@ -1023,7 +1023,7 @@ Multi.prototype.exec = function (callback) {
}, this); }, this);
// TODO - make this callback part of Multi.prototype instead of creating it each time // TODO - make this callback part of Multi.prototype instead of creating it each time
return this.client.send_command("EXEC", [], function (err, replies) { return this._client.send_command("EXEC", [], function (err, replies) {
if (err) { if (err) {
if (callback) { if (callback) {
callback(new Error(err)); callback(new Error(err));

31
test.js
View File

@@ -503,6 +503,37 @@ tests.SCRIPT_LOAD = function() {
}); });
}; };
tests.CLIENT_LIST = function() {
var name = "CLIENT_LIST";
if (!server_version_at_least(client, [2, 4, 0])) {
console.log("Skipping " + name + " for old Redis server version < 2.4.x");
return next(name);
}
function checkResult(result) {
var lines = result.toString().split('\n').slice(0, -1);
assert.strictEqual(lines.length, 4);
assert(lines.every(function(line) {
return line.match(/^addr=/);
}));
}
bclient.client("list", function(err, result) {
console.log(result.toString());
checkResult(result);
client.multi().client("list").exec(function(err, result) {
console.log(result.toString());
checkResult(result);
client.multi([['client', 'list']]).exec(function(err, result) {
console.log(result.toString());
checkResult(result);
next(name);
});
});
});
};
tests.WATCH_MULTI = function () { tests.WATCH_MULTI = function () {
var name = 'WATCH_MULTI', multi; var name = 'WATCH_MULTI', multi;
if (!server_version_at_least(client, [2, 2, 0])) { if (!server_version_at_least(client, [2, 2, 0])) {