Skip to content

Commit

Permalink
Removed hardcodd PUBLIC schema name in case only DB is specified. Fix…
Browse files Browse the repository at this point in the history
…ed request id
  • Loading branch information
smtakeda committed Jan 8, 2018
1 parent 47d32c6 commit 5447ff5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 1 addition & 2 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ func postAuth(
body []byte,
timeout time.Duration) (
data *authResponse, err error) {
requestID := fmt.Sprintf("requestId=%v", uuid.NewV4().String())
params.Add("requestId", requestID)
params.Add("requestId", uuid.NewV4().String())
fullURL := fmt.Sprintf(
"%s://%s:%d%s", sr.Protocol, sr.Host, sr.Port,
"/session/v1/login-request?"+params.Encode())
Expand Down
20 changes: 20 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,26 @@ func TestValidateDatabaseParameter(t *testing.T) {
}
}

func TestSpecifyWarehouseDatabase(t *testing.T) {
dsn := fmt.Sprintf("%s:%s@%s/%s", user, pass, host, dbname)
parameters := url.Values{}
parameters.Add("account", account)
parameters.Add("warehouse", warehouse)
// parameters.Add("role", "nopublic") TODO: create nopublic role for test
if protocol != "" {
parameters.Add("protocol", protocol)
}
db, err := sql.Open("snowflake", dsn+"?"+parameters.Encode())
if err != nil {
t.Fatalf("error creating a connection object: %s", err.Error())
}
defer db.Close()
_, err = db.Exec("SELECT 1")
if err != nil {
t.Fatalf("failed to execute a select 1: %v", err)
}
}

func TestFetchNil(t *testing.T) {
runTests(t, dsn, func(dbt *DBTest) {
rows := dbt.mustQuery("SELECT * FROM values(3,4),(null, 5) order by 2")
Expand Down
1 change: 0 additions & 1 deletion dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func ParseDSN(dsn string) (cfg *Config, err error) {
cfg.Schema = dsn[i+1 : posQuestion]
} else {
cfg.Database = dsn[posSecondSlash+1 : posQuestion]
cfg.Schema = "public"
}
done = true
case dsn[i] == '?':
Expand Down

0 comments on commit 5447ff5

Please sign in to comment.