diff options
Diffstat (limited to 'vendor/github.com/jackc/pgx/v4/stdlib')
| -rw-r--r-- | vendor/github.com/jackc/pgx/v4/stdlib/sql.go | 19 | 
1 files changed, 18 insertions, 1 deletions
| diff --git a/vendor/github.com/jackc/pgx/v4/stdlib/sql.go b/vendor/github.com/jackc/pgx/v4/stdlib/sql.go index da377ecee..f43ae3249 100644 --- a/vendor/github.com/jackc/pgx/v4/stdlib/sql.go +++ b/vendor/github.com/jackc/pgx/v4/stdlib/sql.go @@ -84,7 +84,13 @@ func init() {  		configs: make(map[string]*pgx.ConnConfig),  	}  	fakeTxConns = make(map[*pgx.Conn]*sql.Tx) -	sql.Register("pgx", pgxDriver) + +	// if pgx driver was already registered by different pgx major version then we +	// skip registration under the default name. +	if !contains(sql.Drivers(), "pgx") { +		sql.Register("pgx", pgxDriver) +	} +	sql.Register("pgx/v4", pgxDriver)  	databaseSQLResultFormats = pgx.QueryResultFormatsByOID{  		pgtype.BoolOID:        1, @@ -103,6 +109,17 @@ func init() {  	}  } +// TODO replace by slices.Contains when experimental package will be merged to stdlib +// https://pkg.go.dev/golang.org/x/exp/slices#Contains +func contains(list []string, y string) bool { +	for _, x := range list { +		if x == y { +			return true +		} +	} +	return false +} +  var (  	fakeTxMutex sync.Mutex  	fakeTxConns map[*pgx.Conn]*sql.Tx | 
