Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: client duplicate function now allows db param to be passed #1311

Merged
merged 1 commit into from Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/extendedApi.js
Expand Up @@ -95,7 +95,7 @@ RedisClient.prototype.duplicate = function (options, callback) {
existing_options[elem] = options[elem];
}
var client = new RedisClient(existing_options);
client.selected_db = this.selected_db;
client.selected_db = options.db || this.selected_db;
if (typeof callback === 'function') {
var ready_listener = function () {
callback(null, client);
Expand Down
3 changes: 3 additions & 0 deletions test/node_redis.spec.js
Expand Up @@ -120,11 +120,14 @@ describe('The node_redis client', function () {
});

it('check if all new options replaced the old ones', function (done) {
client.selected_db = 1;
var client2 = client.duplicate({
db: 2,
no_ready_check: true
});
assert(client.connected);
assert(!client2.connected);
assert.notEqual(client.selected_db, client2.selected_db);
assert.strictEqual(client.options.no_ready_check, undefined);
assert.strictEqual(client2.options.no_ready_check, true);
assert.notDeepEqual(client.options, client2.options);
Expand Down