Skip to content

Commit

Permalink
Merge pull request #52 from kanmu/fix_GetConnectorFromConnStr_for_v4
Browse files Browse the repository at this point in the history
Fix GetConnectorFromConnStr for v4
  • Loading branch information
winebarrel authored Dec 4, 2024
2 parents 7d5be5e + 18d30ba commit 5be06d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ func GetConnectorFromURL(u *url.URL) (driver.Connector, error) {
return GetConnectorFromConnStr(u.String())
}

func GetConnectorFromConnStr(connStr string) (driver.Connector, error) {
func GetConnectorFromConnStr(connStr string, opts ...stdlib.OptionOpenDB) (driver.Connector, error) {
cfg, err := pgx.ParseConfig(connStr)

if err != nil {
return nil, err
}

connector := stdlib.GetConnector(*cfg, stdlib.OptionAfterConnect(PrepareStatements))
opts = append(opts, stdlib.OptionAfterConnect(PrepareStatements))
connector := stdlib.GetConnector(*cfg, opts...)

return connector, nil
}
Expand Down

0 comments on commit 5be06d2

Please sign in to comment.