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

pgdriver does not recognize connect_timeout parameter #505

Closed
jessdwitch opened this issue Apr 4, 2022 · 3 comments · Fixed by #507
Closed

pgdriver does not recognize connect_timeout parameter #505

jessdwitch opened this issue Apr 4, 2022 · 3 comments · Fixed by #507
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jessdwitch
Copy link
Contributor

Passing in connect_timeout when connecting via pgdriver results in:
panic: ERROR: unrecognized configuration parameter "connect_timeout" (SQLSTATE=42704)
However, connect_timeout is listed as a valid parameter here at section "34.1.2. Parameter Key Words".

sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN("postgres://postgres:@postgresql:5432/testing?connect_timeout=4&sslmode=disable")))
db := bun.NewDB(sqldb, pgdialect.New())
f := dbfixture.New(db, dbfixture.WithRecreateTables())
if err := f.Load(ctx, os.DirFS("../../testdata"), fixtureName); err != nil {
	panic(err)
}
@vmihailenco
Copy link
Member

That is a param for libpq client, not a PostgreSQL parameter. The Go/pgdriver analog is https://pkg.go.dev/github.com/uptrace/bun/driver/pgdriver#WithDialTimeout

postgres://postgres:@postgresql:5432/testing?dial_timeout=4s&sslmode=disable

But perhaps we should support connect_timeout as well.

@vmihailenco vmihailenco added enhancement New feature or request good first issue Good for newcomers labels Apr 5, 2022
@jessdwitch
Copy link
Contributor Author

😅 That's slightly embarrassing. That sounds like a quick change I'm up for PR-ing though. Would it be more appropriate to create a new WithConnectTimeout or to modify parseDSN to read connect_timeout as a WithDialTimeout?

@vmihailenco
Copy link
Member

or to modify parseDSN to read connect_timeout

This 👍 Perhaps adding something like if d := q.duration("connection_timeout"); d != 0 { here will do, but don't forget to add a test :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants