From 18d30ba9e3d9a0ecc3e0bbe1073c4b5436d08771 Mon Sep 17 00:00:00 2001 From: Genki Sugawara Date: Wed, 4 Dec 2024 14:13:59 +0900 Subject: [PATCH] Update GetConnectorFromConnStr args: Add opts --- db.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db.go b/db.go index 391f1f2..f92e230 100644 --- a/db.go +++ b/db.go @@ -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 }