-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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: postgresql connection URL can use an UNIX Socket #6042
Conversation
Thanks for contribution. You probably don't have to use Also, few other notes:
|
You're welcome!
|
I would like to prevent extra dependencies, because people who use |
That's fine for me. I don't have time to do it this week-end but I can do it next week;) |
@pleerock Seems better now. |
Any update on this? 😄 |
It's ready for merge, waiting for @pleerock to review it. |
I used what's described here and was able to connect from cloud run: #2614 (comment) |
@@ -922,11 +921,12 @@ export class PostgresDriver implements Driver { | |||
*/ | |||
protected async createPool(options: PostgresConnectionOptions, credentials: PostgresConnectionCredentialsOptions): Promise<any> { | |||
|
|||
credentials = Object.assign({}, credentials, DriverUtils.buildDriverOptions(credentials)); // todo: do it better way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this line drops something specifically for Oracle & the URL parsing which we don't want anyway.
Sounds good to me!
Thanks for the contribution! |
Solves #2614.
Users may provide an URL in the connection options which is parsed by a generic function to fill the following fields: host, port, username, password, database.
You can't give an UNIX socket as host with PostgreSQL.
Provide a
ConnectionUrlParser
class with different parser functions. The default parser function is left unchanged to prevent any regression with other database types. Concerning PostgreSQL a new function is provided which solves the issue. To prevent any regression, I tested myself the function with multiples strings against the default parser.postgres://user:password@host:5432/database
(standard)postgres://user:password@/var/run/postgresql?dbname=database
(UNIX socket)postgres:///var/run/postgresql?dbname=database
(without username)