brianc / node-postgres-docs

Documentation for node-postgres
https://node-postgres.com
MIT License
98 stars 94 forks source link

Fix connection string syntax errors #163

Closed kernfeld-cockroach closed 2 years ago

kernfeld-cockroach commented 2 years ago

Remove an extra set of curly braces to fix a syntax error that occurred when trying to create a Pool or Client from a connection string.

netlify[bot] commented 2 years ago

✔️ Hey! A preview of the changes is deployed on netlify to take a look at! :)

🔨 Explore the source changes: 88b7e5bb8aaf8a6c410937343cd4079ebdf61e35

🔍 Inspect the deploy log: https://app.netlify.com/sites/hopeful-clarke-f36d36/deploys/61f2ea659e419200071c74cd

😎 Browse the preview: https://deploy-preview-163--hopeful-clarke-f36d36.netlify.app

charmander commented 2 years ago

This makes it wrong. If the ES6 property shorthand is a syntax error for you, you’re on a very outdated version of Node, or some compilation step is configured to use ES≤5.

kernfeld-cockroach commented 2 years ago

If the ES6 property shorthand is a syntax error for you, you’re on a very outdated version of Node, or some compilation step is configured to use ES≤5.

Hm yes, you're right, this is not necessary. I had my nvm set up wrong to use an old version of Node.

This makes it wrong.

For posterity, I actually think it doesn't, because node-postgres will parse a string if you pass one in. I tested it out with CockroachDB and it does connect to the DB successfully.

charmander commented 2 years ago

It’s not wrong to pass a connection string to pg.Client, but IIRC the Pool constructor doesn’t handle strings (although it probably should).