From 535db5231edb64570eafe1629a24a708b2e6af63 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 1 Mar 2016 17:13:31 +0100 Subject: [PATCH] Fix rename command not working together with key prefixes --- index.js | 10 ++++------ test/rename.spec.js | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 8f755cc9a1..4263786382 100644 --- a/index.js +++ b/index.js @@ -794,17 +794,15 @@ RedisClient.prototype.send_command = function (command, args, callback) { } this.command_queue.push(command_obj); - if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) { - command = this.options.rename_commands[command]; - } if (this.options.prefix) { prefix_keys = commands.getKeyIndexes(command, args_copy); - i = prefix_keys.pop(); - while (i !== undefined) { + for (i = prefix_keys.pop(); i !== undefined; i = prefix_keys.pop()) { args_copy[i] = this.options.prefix + args_copy[i]; - i = prefix_keys.pop(); } } + if (typeof this.options.rename_commands !== 'undefined' && this.options.rename_commands[command]) { + command = this.options.rename_commands[command]; + } // Always use 'Multi bulk commands', but if passed any Buffer args, then do multiple writes, one for each arg. // This means that using Buffers in commands is going to be slower, so use Strings if you don't already have a Buffer. command_str = '*' + (len + 1) + '\r\n$' + command.length + '\r\n' + command + '\r\n'; diff --git a/test/rename.spec.js b/test/rename.spec.js index 9607210567..e829323c82 100644 --- a/test/rename.spec.js +++ b/test/rename.spec.js @@ -27,7 +27,7 @@ describe("rename commands", function () { }); client.on('ready', function () { - done(); + client.flushdb(done); }); });