Skip to content

Commit

Permalink
fix(go/adbc/driver/snowflake): prevent database options from getting …
Browse files Browse the repository at this point in the history
…overwritten (#1097)

Fixes #1074
  • Loading branch information
joellubi authored Sep 22, 2023
1 parent 0d8707a commit 8a832d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions go/adbc/driver/snowflake/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func (d *database) SetOptions(cnOptions map[string]string) error {

var err error
for k, v := range cnOptions {
v := v // copy into loop scope
switch k {
case adbc.OptionKeyUsername:
d.cfg.User = v
Expand Down
22 changes: 22 additions & 0 deletions go/adbc/driver/snowflake/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,25 @@ func (suite *SnowflakeTests) TestMetadataGetObjectsColumnsXdbc() {
})
}
}

func (suite *SnowflakeTests) TestNewDatabaseGetSetOptions() {
key1, val1 := "key1", "val1"
key2, val2 := "key2", "val2"

db, err := suite.driver.NewDatabase(map[string]string{
key1: val1,
key2: val2,
})
suite.NoError(err)
suite.NotNil(db)

getSetDB, ok := db.(adbc.GetSetOptions)
suite.True(ok)

optVal1, err := getSetDB.GetOption(key1)
suite.NoError(err)
suite.Equal(optVal1, val1)
optVal2, err := getSetDB.GetOption(key2)
suite.NoError(err)
suite.Equal(optVal2, val2)
}

0 comments on commit 8a832d6

Please sign in to comment.