From 0b50c1628177b60b46fc37d00a1071313f58e21c Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Wed, 1 May 2024 15:55:43 -0700 Subject: [PATCH 1/2] [mssql] Rename `DefaultDialect` to `MSSQLDialect` --- clients/mssql/store.go | 2 +- clients/mssql/tableid.go | 2 +- lib/destination/dml/merge_mssql_test.go | 4 ++-- lib/destination/dml/merge_parts_test.go | 4 ++-- lib/sql/dialect.go | 6 +++--- lib/sql/dialect_test.go | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clients/mssql/store.go b/clients/mssql/store.go index bff06ab4c..73c6abb05 100644 --- a/clients/mssql/store.go +++ b/clients/mssql/store.go @@ -36,7 +36,7 @@ func (s *Store) Label() constants.DestinationKind { } func (s *Store) Dialect() sql.Dialect { - return sql.DefaultDialect{} + return sql.MSSQLDialect{} } func (s *Store) Merge(tableData *optimization.TableData) error { diff --git a/clients/mssql/tableid.go b/clients/mssql/tableid.go index b5026d723..ddfe37a2f 100644 --- a/clients/mssql/tableid.go +++ b/clients/mssql/tableid.go @@ -7,7 +7,7 @@ import ( "github.com/artie-labs/transfer/lib/sql" ) -var dialect = sql.DefaultDialect{} +var dialect = sql.MSSQLDialect{} type TableIdentifier struct { schema string diff --git a/lib/destination/dml/merge_mssql_test.go b/lib/destination/dml/merge_mssql_test.go index 53174fdad..505d333da 100644 --- a/lib/destination/dml/merge_mssql_test.go +++ b/lib/destination/dml/merge_mssql_test.go @@ -44,10 +44,10 @@ func Test_GetMSSQLStatement(t *testing.T) { TableID: MockTableIdentifier{fqTable}, SubQuery: subQuery, IdempotentKey: "", - PrimaryKeys: []columns.Wrapper{columns.NewWrapper(columns.NewColumn("id", typing.Invalid), sql.DefaultDialect{})}, + PrimaryKeys: []columns.Wrapper{columns.NewWrapper(columns.NewColumn("id", typing.Invalid), sql.MSSQLDialect{})}, Columns: &_cols, DestKind: constants.MSSQL, - Dialect: sql.DefaultDialect{}, + Dialect: sql.MSSQLDialect{}, SoftDelete: false, } diff --git a/lib/destination/dml/merge_parts_test.go b/lib/destination/dml/merge_parts_test.go index ffba67a61..1b7038a70 100644 --- a/lib/destination/dml/merge_parts_test.go +++ b/lib/destination/dml/merge_parts_test.go @@ -48,10 +48,10 @@ func getBasicColumnsForTest(compositeKey bool) result { cols.AddColumn(columns.NewColumn(constants.DeleteColumnMarker, typing.Boolean)) var pks []columns.Wrapper - pks = append(pks, columns.NewWrapper(idCol, sql.DefaultDialect{})) + pks = append(pks, columns.NewWrapper(idCol, sql.MSSQLDialect{})) if compositeKey { - pks = append(pks, columns.NewWrapper(emailCol, sql.DefaultDialect{})) + pks = append(pks, columns.NewWrapper(emailCol, sql.MSSQLDialect{})) } return result{ diff --git a/lib/sql/dialect.go b/lib/sql/dialect.go index 4eee6297d..c46cb14bd 100644 --- a/lib/sql/dialect.go +++ b/lib/sql/dialect.go @@ -15,11 +15,11 @@ type Dialect interface { QuoteIdentifier(identifier string) string } -type DefaultDialect struct{} +type MSSQLDialect struct{} -func (DefaultDialect) NeedsEscaping(_ string) bool { return true } +func (MSSQLDialect) NeedsEscaping(_ string) bool { return true } -func (DefaultDialect) QuoteIdentifier(identifier string) string { +func (MSSQLDialect) QuoteIdentifier(identifier string) string { return fmt.Sprintf(`"%s"`, identifier) } diff --git a/lib/sql/dialect_test.go b/lib/sql/dialect_test.go index 9f1088077..18516baa0 100644 --- a/lib/sql/dialect_test.go +++ b/lib/sql/dialect_test.go @@ -7,7 +7,7 @@ import ( ) func TestDefaultDialect_QuoteIdentifier(t *testing.T) { - dialect := DefaultDialect{} + dialect := MSSQLDialect{} assert.Equal(t, `"foo"`, dialect.QuoteIdentifier("foo")) assert.Equal(t, `"FOO"`, dialect.QuoteIdentifier("FOO")) } From 43eabc9b86d6f3fa29b3a252b5f22313c102051f Mon Sep 17 00:00:00 2001 From: Nathan Villaescusa Date: Wed, 1 May 2024 15:57:01 -0700 Subject: [PATCH 2/2] Rename --- lib/sql/dialect_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sql/dialect_test.go b/lib/sql/dialect_test.go index 18516baa0..adee0a481 100644 --- a/lib/sql/dialect_test.go +++ b/lib/sql/dialect_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestDefaultDialect_QuoteIdentifier(t *testing.T) { +func TestMSSQLDialect_QuoteIdentifier(t *testing.T) { dialect := MSSQLDialect{} assert.Equal(t, `"foo"`, dialect.QuoteIdentifier("foo")) assert.Equal(t, `"FOO"`, dialect.QuoteIdentifier("FOO"))