From 145eaabebd1886b22a1d992352f6d50fd7e00bd2 Mon Sep 17 00:00:00 2001 From: Nathan <148575555+nathan-artie@users.noreply.github.com> Date: Wed, 1 May 2024 15:37:30 -0700 Subject: [PATCH] [sql] Rename `EscapeNameIfNecessaryUsingDialog` (#531) --- clients/snowflake/snowflake.go | 4 ++-- lib/destination/dml/merge.go | 6 +++--- lib/sql/escape.go | 2 +- lib/typing/columns/columns.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clients/snowflake/snowflake.go b/clients/snowflake/snowflake.go index eec3b4dda..372e7c3df 100644 --- a/clients/snowflake/snowflake.go +++ b/clients/snowflake/snowflake.go @@ -134,12 +134,12 @@ func (s *Store) reestablishConnection() error { func (s *Store) generateDedupeQueries(tableID, stagingTableID types.TableIdentifier, primaryKeys []string, topicConfig kafkalib.TopicConfig) []string { var primaryKeysEscaped []string for _, pk := range primaryKeys { - primaryKeysEscaped = append(primaryKeysEscaped, sql.EscapeNameIfNecessaryUsingDialect(pk, s.Dialect())) + primaryKeysEscaped = append(primaryKeysEscaped, sql.EscapeNameIfNecessary(pk, s.Dialect())) } orderColsToIterate := primaryKeysEscaped if topicConfig.IncludeArtieUpdatedAt { - orderColsToIterate = append(orderColsToIterate, sql.EscapeNameIfNecessaryUsingDialect(constants.UpdateColumnMarker, s.Dialect())) + orderColsToIterate = append(orderColsToIterate, sql.EscapeNameIfNecessary(constants.UpdateColumnMarker, s.Dialect())) } var orderByCols []string diff --git a/lib/destination/dml/merge.go b/lib/destination/dml/merge.go index 0c69a0d82..8e27504ae 100644 --- a/lib/destination/dml/merge.go +++ b/lib/destination/dml/merge.go @@ -134,7 +134,7 @@ func (m *MergeArgument) GetParts() ([]string, error) { // We also need to remove __artie flags since it does not exist in the destination table var removed bool for idx, col := range cols { - if col == sql.EscapeNameIfNecessaryUsingDialect(constants.DeleteColumnMarker, m.Dialect) { + if col == sql.EscapeNameIfNecessary(constants.DeleteColumnMarker, m.Dialect) { cols = append(cols[:idx], cols[idx+1:]...) removed = true break @@ -257,7 +257,7 @@ WHEN NOT MATCHED AND IFNULL(cc.%s, false) = false THEN INSERT (%s) VALUES (%s);` // We also need to remove __artie flags since it does not exist in the destination table var removed bool for idx, col := range cols { - if col == sql.EscapeNameIfNecessaryUsingDialect(constants.DeleteColumnMarker, m.Dialect) { + if col == sql.EscapeNameIfNecessary(constants.DeleteColumnMarker, m.Dialect) { cols = append(cols[:idx], cols[idx+1:]...) removed = true break @@ -327,7 +327,7 @@ WHEN NOT MATCHED AND COALESCE(cc.%s, 0) = 0 THEN INSERT (%s) VALUES (%s);`, // We also need to remove __artie flags since it does not exist in the destination table var removed bool for idx, col := range cols { - if col == sql.EscapeNameIfNecessaryUsingDialect(constants.DeleteColumnMarker, m.Dialect) { + if col == sql.EscapeNameIfNecessary(constants.DeleteColumnMarker, m.Dialect) { cols = append(cols[:idx], cols[idx+1:]...) removed = true break diff --git a/lib/sql/escape.go b/lib/sql/escape.go index 60e330f41..c1f34bda7 100644 --- a/lib/sql/escape.go +++ b/lib/sql/escape.go @@ -1,6 +1,6 @@ package sql -func EscapeNameIfNecessaryUsingDialect(name string, dialect Dialect) string { +func EscapeNameIfNecessary(name string, dialect Dialect) string { if dialect.NeedsEscaping(name) { return dialect.QuoteIdentifier(name) } diff --git a/lib/typing/columns/columns.go b/lib/typing/columns/columns.go index 78fad212f..386d74ea8 100644 --- a/lib/typing/columns/columns.go +++ b/lib/typing/columns/columns.go @@ -87,7 +87,7 @@ func (c *Column) RawName() string { // Plus we will escape it if the column name is part of the reserved words from destinations. // If so, it'll change from `start` => `"start"` as suggested by Snowflake. func (c *Column) Name(dialect sql.Dialect) string { - return sql.EscapeNameIfNecessaryUsingDialect(c.name, dialect) + return sql.EscapeNameIfNecessary(c.name, dialect) } type Columns struct {