From e0d1ef5c718f9e1e58e80d31bbe2d2f27afec486 Mon Sep 17 00:00:00 2001 From: Scott Winkler Date: Wed, 1 Feb 2023 14:14:39 -0800 Subject: [PATCH] fix: misc linting changes for 0.56.2 (#1509) * fix: tag-associations formatting * fix: tag-associations formatting * fix: tag-associations formatting --- pkg/snowflake/tag_association.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pkg/snowflake/tag_association.go b/pkg/snowflake/tag_association.go index c37d53f071..b19a285f4a 100644 --- a/pkg/snowflake/tag_association.go +++ b/pkg/snowflake/tag_association.go @@ -61,12 +61,11 @@ func (tb *TagAssociationBuilder) GetTagSchema() string { func (tb *TagAssociationBuilder) GetTableAndColumnName() (string, string) { if strings.ToUpper(tb.objectType) != "COLUMN" { return tb.objectIdentifier, "" - } else { - splObjIdentifier := strings.Split(tb.objectIdentifier, ".") - tableName := strings.ReplaceAll(splObjIdentifier[2], "\"", "") - columnName := strings.ReplaceAll(splObjIdentifier[3], "\"", "") - return fmt.Sprintf(`"%s"."%s"."%s"`, tb.databaseName, tb.schemaName, tableName), columnName } + splObjIdentifier := strings.Split(tb.objectIdentifier, ".") + tableName := strings.ReplaceAll(splObjIdentifier[2], "\"", "") + columnName := strings.ReplaceAll(splObjIdentifier[3], "\"", "") + return fmt.Sprintf(`"%s"."%s"."%s"`, tb.databaseName, tb.schemaName, tableName), columnName } // TagAssociation returns a pointer to a Builder that abstracts the DDL operations for a tag sssociation. @@ -91,9 +90,8 @@ func (tb *TagAssociationBuilder) Create() string { if strings.ToUpper(tb.objectType) == "COLUMN" { tableName, columnName := tb.GetTableAndColumnName() return fmt.Sprintf(`ALTER TABLE %v MODIFY COLUMN %v SET TAG "%v"."%v"."%v" = '%v'`, tableName, columnName, tb.databaseName, tb.schemaName, tb.tagName, EscapeString(tb.tagValue)) - } else { - return fmt.Sprintf(`ALTER %v %v SET TAG "%v"."%v"."%v" = '%v'`, tb.objectType, tb.objectIdentifier, tb.databaseName, tb.schemaName, tb.tagName, EscapeString(tb.tagValue)) } + return fmt.Sprintf(`ALTER %v %v SET TAG "%v"."%v"."%v" = '%v'`, tb.objectType, tb.objectIdentifier, tb.databaseName, tb.schemaName, tb.tagName, EscapeString(tb.tagValue)) } // Drop returns the SQL query that will remove a tag from an object. @@ -101,9 +99,8 @@ func (tb *TagAssociationBuilder) Drop() string { if strings.ToUpper(tb.objectType) == "COLUMN" { tableName, columnName := tb.GetTableAndColumnName() return fmt.Sprintf(`ALTER TABLE %v MODIFY COLUMN %v UNSET TAG "%v"."%v"."%v"`, tableName, columnName, tb.databaseName, tb.schemaName, tb.tagName) - } else { - return fmt.Sprintf(`ALTER %v %v UNSET TAG "%v"."%v"."%v"`, tb.objectType, tb.objectIdentifier, tb.databaseName, tb.schemaName, tb.tagName) } + return fmt.Sprintf(`ALTER %v %v UNSET TAG "%v"."%v"."%v"`, tb.objectType, tb.objectIdentifier, tb.databaseName, tb.schemaName, tb.tagName) } // Show returns the SQL query that will show the current tag value on an object. @@ -112,9 +109,8 @@ func (tb *TagAssociationBuilder) Show() string { fqTableName, columnName := tb.GetTableAndColumnName() fqColumnName := fmt.Sprintf(`%v."%v"`, fqTableName, columnName) return fmt.Sprintf(`SELECT SYSTEM$GET_TAG('"%v"."%v"."%v"', '%v', '%v') TAG_VALUE WHERE TAG_VALUE IS NOT NULL`, tb.databaseName, tb.schemaName, tb.tagName, fqColumnName, tb.objectType) - } else { - return fmt.Sprintf(`SELECT SYSTEM$GET_TAG('"%v"."%v"."%v"', '%v', '%v') TAG_VALUE WHERE TAG_VALUE IS NOT NULL`, tb.databaseName, tb.schemaName, tb.tagName, tb.objectIdentifier, tb.objectType) } + return fmt.Sprintf(`SELECT SYSTEM$GET_TAG('"%v"."%v"."%v"', '%v', '%v') TAG_VALUE WHERE TAG_VALUE IS NOT NULL`, tb.databaseName, tb.schemaName, tb.tagName, tb.objectIdentifier, tb.objectType) } func ScanTagAssociation(row *sqlx.Row) (*TagAssociation, error) {