Skip to content

Commit

Permalink
Merge branch 'master' into refactor-snowflake-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Jan 20, 2025
2 parents f9260d2 + e031971 commit 1ca44cc
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clients/bigquery/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type BigQueryDialect struct{}

func (BigQueryDialect) QuoteIdentifier(identifier string) string {
// BigQuery needs backticks to quote.
return fmt.Sprintf("`%s`", identifier)
return fmt.Sprintf("`%s`", strings.ReplaceAll(identifier, "`", ""))
}

func (BigQueryDialect) EscapeStruct(value string) string {
Expand Down
1 change: 1 addition & 0 deletions clients/bigquery/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestBigQueryDialect_QuoteIdentifier(t *testing.T) {
dialect := BigQueryDialect{}
assert.Equal(t, "`foo`", dialect.QuoteIdentifier("foo"))
assert.Equal(t, "`FOO`", dialect.QuoteIdentifier("FOO"))
assert.Equal(t, "`FOO; BAD`", dialect.QuoteIdentifier("FOO`; BAD"))
}

func TestBigQueryDialect_IsColumnAlreadyExistsErr(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion clients/databricks/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type DatabricksDialect struct{}

func (DatabricksDialect) QuoteIdentifier(identifier string) string {
return fmt.Sprintf("`%s`", identifier)
return fmt.Sprintf("`%s`", strings.ReplaceAll(identifier, "`", ""))
}

func (DatabricksDialect) EscapeStruct(value string) string {
Expand Down
1 change: 1 addition & 0 deletions clients/databricks/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestDatabricksDialect_QuoteIdentifier(t *testing.T) {
dialect := DatabricksDialect{}
assert.Equal(t, "`foo`", dialect.QuoteIdentifier("foo"))
assert.Equal(t, "`FOO`", dialect.QuoteIdentifier("FOO"))
assert.Equal(t, "`FOO; BAD`", dialect.QuoteIdentifier("FOO`; BAD"))
}

func TestDatabricksDialect_IsColumnAlreadyExistsErr(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion clients/mssql/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
type MSSQLDialect struct{}

func (MSSQLDialect) QuoteIdentifier(identifier string) string {
return fmt.Sprintf(`"%s"`, identifier)
return fmt.Sprintf(`"%s"`, strings.ReplaceAll(identifier, `"`, ``))
}

func (MSSQLDialect) EscapeStruct(value string) string {
Expand Down
1 change: 1 addition & 0 deletions clients/mssql/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestMSSQLDialect_QuoteIdentifier(t *testing.T) {
dialect := MSSQLDialect{}
assert.Equal(t, `"foo"`, dialect.QuoteIdentifier("foo"))
assert.Equal(t, `"FOO"`, dialect.QuoteIdentifier("FOO"))
assert.Equal(t, `"FOO; BAD"`, dialect.QuoteIdentifier(`FOO"; BAD`))
}

func TestMSSQLDialect_IsColumnAlreadyExistsErr(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion clients/redshift/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type RedshiftDialect struct{}

func (rd RedshiftDialect) QuoteIdentifier(identifier string) string {
// Preserve the existing behavior of Redshift identifiers being lowercased due to not being quoted.
return fmt.Sprintf(`"%s"`, strings.ToLower(identifier))
return fmt.Sprintf(`"%s"`, strings.ToLower(strings.ReplaceAll(identifier, `"`, ``)))
}

func (RedshiftDialect) EscapeStruct(value string) string {
Expand Down
1 change: 1 addition & 0 deletions clients/redshift/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestRedshiftDialect_QuoteIdentifier(t *testing.T) {
dialect := RedshiftDialect{}
assert.Equal(t, `"foo"`, dialect.QuoteIdentifier("foo"))
assert.Equal(t, `"foo"`, dialect.QuoteIdentifier("FOO"))
assert.Equal(t, `"foo; bad"`, dialect.QuoteIdentifier(`FOO"; BAD`))
}

func TestRedshiftDialect_IsColumnAlreadyExistsErr(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion clients/snowflake/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type SnowflakeDialect struct{}

func (SnowflakeDialect) QuoteIdentifier(identifier string) string {
return fmt.Sprintf(`"%s"`, strings.ToUpper(identifier))
return fmt.Sprintf(`"%s"`, strings.ToUpper(strings.ReplaceAll(identifier, `"`, ``)))
}

func (SnowflakeDialect) EscapeStruct(value string) string {
Expand Down
1 change: 1 addition & 0 deletions clients/snowflake/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func TestSnowflakeDialect_QuoteIdentifier(t *testing.T) {
dialect := SnowflakeDialect{}
assert.Equal(t, `"FOO"`, dialect.QuoteIdentifier("foo"))
assert.Equal(t, `"FOO"`, dialect.QuoteIdentifier("FOO"))
assert.Equal(t, `"FOO; BAD"`, dialect.QuoteIdentifier(`FOO"; BAD`))
}

func TestSnowflakeDialect_IsTableDoesNotExistErr(t *testing.T) {
Expand Down

0 comments on commit 1ca44cc

Please sign in to comment.