Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed May 22, 2024
1 parent 8a6b67a commit 09a52d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions pkg/sdk/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Databases interface {
Show(ctx context.Context, opts *ShowDatabasesOptions) ([]Database, error)
ShowByID(ctx context.Context, id AccountObjectIdentifier) (*Database, error)
Describe(ctx context.Context, id AccountObjectIdentifier) (*DatabaseDetails, error)
Use(ctx context.Context, id AccountObjectIdentifier) error
}

var _ Databases = (*databases)(nil)
Expand Down Expand Up @@ -682,3 +683,9 @@ func (v *databases) Describe(ctx context.Context, id AccountObjectIdentifier) (*
}
return &details, err
}

// Use is based on https://docs.snowflake.com/en/sql-reference/sql/use-database.
func (v *databases) Use(ctx context.Context, id AccountObjectIdentifier) error {
// proxy to sessions
return v.client.Sessions.UseDatabase(ctx, id)
}
10 changes: 2 additions & 8 deletions pkg/sdk/testint/databases_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ func TestInt_DatabasesCreateShared(t *testing.T) {
},
})
require.NoError(t, err)
t.Cleanup(func() {
err = client.Databases.Drop(ctx, sharedDatabase.ID(), nil)
require.NoError(t, err)
})
t.Cleanup(testClientHelper().Database.DropDatabaseFunc(t, sharedDatabase.ID()))

database, err := client.Databases.ShowByID(ctx, sharedDatabase.ID())
require.NoError(t, err)
Expand Down Expand Up @@ -270,10 +267,7 @@ func TestInt_DatabasesCreateSecondary(t *testing.T) {
Comment: sdk.String(comment),
})
require.NoError(t, err)
t.Cleanup(func() {
err = client.Databases.Drop(ctx, sharedDatabase.ID(), nil)
require.NoError(t, err)
})
t.Cleanup(testClientHelper().Database.DropDatabaseFunc(t, sharedDatabase.ID()))

database, err := client.Databases.ShowByID(ctx, sharedDatabase.ID())
require.NoError(t, err)
Expand Down

0 comments on commit 09a52d0

Please sign in to comment.