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

Add selected_db to the new redis instance if using client.duplicate

This commit is contained in:
Ruben Bridgewater
2015-11-23 14:27:10 +01:00
parent 9ca2d1ddaa
commit b5fe822553
2 changed files with 5 additions and 1 deletions

View File

@@ -141,7 +141,9 @@ RedisClient.prototype.duplicate = function (options) {
for (var elem in options) { // jshint ignore: line
existing_options[elem] = options[elem];
}
return new RedisClient(existing_options);
var client = new RedisClient(existing_options);
client.selected_db = this.selected_db;
return client;
};
RedisClient.prototype.initialize_retry_vars = function () {

View File

@@ -44,7 +44,9 @@ describe("The node_redis client", function () {
describe('duplicate', function () {
it('check if all options got copied properly', function(done) {
client.selected_db = 2;
var client2 = client.duplicate();
assert.strictEqual(client2.selected_db, 2);
assert(client.connected);
assert(!client2.connected);
for (var elem in client.options) {