From 71da600c3aef590a7c705ea4565f8464ce4517f5 Mon Sep 17 00:00:00 2001 From: Isabel Jimenez Date: Fri, 11 Feb 2022 01:03:10 -0800 Subject: [PATCH] exposing stdlib DB connector --- stdlib/sql.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/sql.go b/stdlib/sql.go index fa81e73d..da377ece 100644 --- a/stdlib/sql.go +++ b/stdlib/sql.go @@ -163,7 +163,7 @@ func RandomizeHostOrderFunc(ctx context.Context, connConfig *pgx.ConnConfig) err return nil } -func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { +func GetConnector(config pgx.ConnConfig, opts ...OptionOpenDB) driver.Connector { c := connector{ ConnConfig: config, BeforeConnect: func(context.Context, *pgx.ConnConfig) error { return nil }, // noop before connect by default @@ -175,7 +175,11 @@ func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { for _, opt := range opts { opt(&c) } + return c +} +func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB { + c := GetConnector(config, opts...) return sql.OpenDB(c) }