Skip to content

Commit ce3db31

Browse files
authored
SNOW-1814531 Implement DriverContext interface (#1248)
1 parent 11cccfd commit ce3db31

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

auth_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,6 @@ func TestOktaRetryWithNewToken(t *testing.T) {
979979
}
980980

981981
func TestContextPropagatedToAuthWhenUsingOpen(t *testing.T) {
982-
t.Skip("dsnConnector loses context when opening using sql.Open")
983982
db, err := sql.Open("snowflake", dsn)
984983
assertNilF(t, err)
985984
defer db.Close()

connector.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type Connector struct {
2020
}
2121

2222
// NewConnector creates a new connector with the given SnowflakeDriver and Config.
23-
func NewConnector(driver InternalSnowflakeDriver, config Config) Connector {
23+
func NewConnector(driver InternalSnowflakeDriver, config Config) driver.Connector {
2424
return Connector{driver, config}
2525
}
2626

driver.go

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ func (d SnowflakeDriver) Open(dsn string) (driver.Conn, error) {
3333
return d.OpenWithConfig(ctx, *cfg)
3434
}
3535

36+
// OpenConnector creates a new connector with parsed DSN.
37+
func (d SnowflakeDriver) OpenConnector(dsn string) (driver.Connector, error) {
38+
cfg, err := ParseDSN(dsn)
39+
if err != nil {
40+
return Connector{}, err
41+
}
42+
return NewConnector(d, *cfg), nil
43+
}
44+
3645
// OpenWithConfig creates a new connection with the given Config.
3746
func (d SnowflakeDriver) OpenWithConfig(ctx context.Context, config Config) (driver.Conn, error) {
3847
if err := config.Validate(); err != nil {

0 commit comments

Comments
 (0)