The postgres lib cannot parse my url string correctly to connect to my local postgresql
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
I try to set postgresql://user@localhost/db?host=/run/postgresql and postgresql:///db?host=/run/postgresql but seems it doesn't work. You get replace all query parameters here
Specification:
https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS
You can use pg-connection-string package
but actually we can use URL to parse it
new URL('postgresql://user:pass@localhost:5432/db?host=/run/postgresql')
URL {
href: 'postgresql://user:pass@localhost:5432/db?host=/run/postgresql',
origin: 'null',
protocol: 'postgresql:',
username: 'user',
password: 'pass',
host: 'localhost:5432',
hostname: 'localhost',
port: '5432',
pathname: '/db',
search: '?host=/run/postgresql',
searchParams: URLSearchParams { 'host' => '/run/postgresql' },
hash: ''
}
new URL('postgresql:///db?host=/run/postgresql')
URL {
href: 'postgresql:///db?host=/run/postgresql',
origin: 'null',
protocol: 'postgresql:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/db',
search: '?host=/run/postgresql',
searchParams: URLSearchParams { 'host' => '/run/postgresql' },
hash: ''
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the query-parameter handling in src/index.js around line 540, then compare it with the PostgreSQL URI specification and the provided URL examples. Ensure connection strings using host query parameters, including Unix socket paths, are parsed correctly; the issue does not mention a specific test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100