diff --git a/clients/mssql/dialect/dialect.go b/clients/mssql/dialect/dialect.go index ec8f43bdc..c39eca892 100644 --- a/clients/mssql/dialect/dialect.go +++ b/clients/mssql/dialect/dialect.go @@ -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 { diff --git a/clients/mssql/dialect/dialect_test.go b/clients/mssql/dialect/dialect_test.go index 5386048cd..0470491e7 100644 --- a/clients/mssql/dialect/dialect_test.go +++ b/clients/mssql/dialect/dialect_test.go @@ -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'`,