Skip to content

Commit

Permalink
Implement MSSQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Sep 26, 2024
1 parent ef7ecba commit 0257563
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions clients/mssql/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ func (MSSQLDialect) BuildAlterColumnQuery(tableID sql.TableIdentifier, columnOp
return fmt.Sprintf("ALTER TABLE %s %s %s", tableID.FullyQualifiedName(), columnOp, colSQLPart)
}

func (MSSQLDialect) BuildIncreaseStringPrecisionQuery(tableID sql.TableIdentifier, column columns.Column, newPrecision int32) string {
// TODO: Implement this
return ""
func (md MSSQLDialect) BuildIncreaseStringPrecisionQuery(tableID sql.TableIdentifier, column columns.Column, newPrecision int32) string {
return fmt.Sprintf("ALTER TABLE %s ALTER COLUMN %s VARCHAR(%d)", tableID.FullyQualifiedName(), md.QuoteIdentifier(column.Name()), newPrecision)
}

func (md MSSQLDialect) BuildIsNotToastValueExpression(tableAlias constants.TableAlias, column columns.Column) string {
Expand Down
10 changes: 10 additions & 0 deletions clients/mssql/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ func TestMSSQLDialect_BuildAlterColumnQuery(t *testing.T) {
)
}

func TestMSSQLDialect_BuildIncreaseStringPrecisionQuery(t *testing.T) {
fakeTableID := &mocks.FakeTableIdentifier{}
fakeTableID.FullyQualifiedNameReturns("{TABLE}")

assert.Equal(t,
`ALTER TABLE {TABLE} ALTER COLUMN "{COLUMN}" VARCHAR(12345)`,
MSSQLDialect{}.BuildIncreaseStringPrecisionQuery(fakeTableID, columns.NewColumn("{COLUMN}", typing.String), 12345),
)
}

func TestMSSQLDialect_BuildIsNotToastValueExpression(t *testing.T) {
assert.Equal(t,
`COALESCE(tbl."bar", '') != '__debezium_unavailable_value'`,
Expand Down

0 comments on commit 0257563

Please sign in to comment.