Skip to content

Commit

Permalink
fix: Database tags UNSET (Snowflake-Labs#1256)
Browse files Browse the repository at this point in the history
* Fixed addressing the tag with a fully qualified identifier
* fixed UNSET by removing value in statement
(see https://docs.snowflake.com/en/sql-reference/sql/alter-database.html#syntax)
  • Loading branch information
christophkreutzer committed Oct 6, 2022
1 parent b9bf009 commit af5db03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/snowflake/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ func (db *DatabaseBuilder) WithTags(tags []TagValue) *DatabaseBuilder {

// AddTag returns the SQL query that will add a new tag to the database.
func (db *DatabaseBuilder) AddTag(tag TagValue) string {
return fmt.Sprintf(`ALTER DATABASE %s SET TAG "%v" = "%v"`, db.QualifiedName(), tag.Name, tag.Value)
return fmt.Sprintf(`ALTER DATABASE %s SET TAG "%v"."%v"."%v" = "%v"`, db.QualifiedName(), tag.Database, tag.Schema, tag.Name, tag.Value)
}

// ChangeTag returns the SQL query that will alter a tag on the database.
func (db *DatabaseBuilder) ChangeTag(tag TagValue) string {
return fmt.Sprintf(`ALTER DATABASE %s SET TAG "%v" = "%v"`, db.QualifiedName(), tag.Name, tag.Value)
return fmt.Sprintf(`ALTER DATABASE %s SET TAG "%v"."%v"."%v" = "%v"`, db.QualifiedName(), tag.Database, tag.Schema, tag.Name, tag.Value)
}

// UnsetTag returns the SQL query that will unset a tag on the database.
func (db *DatabaseBuilder) UnsetTag(tag TagValue) string {
return fmt.Sprintf(`ALTER DATABASE %s UNSET TAG "%v" = "%v"`, db.QualifiedName(), tag.Name, tag.Value)
return fmt.Sprintf(`ALTER DATABASE %s UNSET TAG "%v"."%v"."%v"`, db.QualifiedName(), tag.Database, tag.Schema, tag.Name)
}

// Database returns a pointer to a Builder that abstracts the DDL operations for a database.
Expand Down

0 comments on commit af5db03

Please sign in to comment.