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

feat(pg-connection-string): ClientConfig helper functions #3128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hjr3
Copy link
Contributor

@hjr3 hjr3 commented Jan 17, 2024

Two new functions are introduced to make it easy for TypeScript users to use a PostgresSQL connection string with pg Client.

Fixes #2280

Two new functions are introduced to make it easy for TypeScript
users to use a PostgresSQL connection string with pg Client.

Fixes brianc#2280
@hjr3
Copy link
Contributor Author

hjr3 commented Jan 17, 2024

I will rebase once #3122 lands

const config = parse('socket:/some path/?db=my[db]&encoding=utf8&client_encoding=bogus')
const clientConfig = toClientConfig(config)
clientConfig.host.should.equal('/some path/')
clientConfig.database.should.equal('my[db]', 'must to be escaped and unescaped through "my%5Bdb%5D"')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should've thrown an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is current behavior according to:

subject.database.should.equal('my[db]', 'must to be escaped and unescaped trough "my%5Bdb%5D"')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pg-connection-string ConnectionOptions interface is not compatible with PoolConfig
2 participants