redis / redis/node-redis

db options does not fire select db on createClient when url (with specified db number) is provided

Open
#1,477 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

  • Version: 2.8.0
  • Platform: Node JS 12.8.0 on MacOS Mojave 10.14.5
  • Description:
    as the title said, I expect when the db option is provided, it will fire select command on connect using the db option provided regardless whether url provides db number or not.

How to reproduce:

const redis = require('redis')
const url = 'redis://127.0.0.1:6379/0'
const client = redis.createClient({db: 3, url: url})
client.selected_db // this will return 0, instead of 3 which I expect
client.set('foo', 'bar') // upon checking on redis-cli this is written to db 0, not on db 3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the createClient option handling for the URL and db settings, then reproduce the provided Node.js example with Redis. Done means a client created with db: 3 selects database 3 even when the URL contains /0, and writes from client.set go to database 3.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, redis
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.