Skip to content

Commit

Permalink
[hotfix][cdc-connector][mysql] Fix the default length of CHAR data ty…
Browse files Browse the repository at this point in the history
…pe of Add column DDL
  • Loading branch information
zhongqs committed Mar 19, 2024
1 parent 2d5fe19 commit 5c4d5f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static DataType convertFromColumn(Column column) {
? DataTypes.TIMESTAMP_LTZ(column.length())
: DataTypes.TIMESTAMP_LTZ(0);
case CHAR:
return DataTypes.CHAR(column.length());
return DataTypes.CHAR(column.length() > 0 ? column.length() : 1);
case VARCHAR:
return DataTypes.VARCHAR(column.length());
case TINYTEXT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ public void testParseAlterStatement() throws Exception {
Collections.singletonList(
new AddColumnEvent.ColumnWithPosition(
Column.physicalColumn("cols6", DataTypes.BINARY(1))))));
statement.execute(
String.format(
"ALTER TABLE `%s`.`products` ADD COLUMN `cols7` CHAR NULL;",
inventoryDatabase.getDatabaseName()));
expected.add(
new AddColumnEvent(
tableId,
Collections.singletonList(
new AddColumnEvent.ColumnWithPosition(
Column.physicalColumn("cols7", DataTypes.CHAR(1))))));
}
List<Event> actual = fetchResults(events, expected.size());
assertThat(actual).isEqualTo(expected);
Expand Down

0 comments on commit 5c4d5f2

Please sign in to comment.