Skip to content

Commit 25fa95e

Browse files
authored
[FLINK-38641][cdc/mysql] Unquote double quotes from default values on MySQL (#4171)
1 parent 55aff6e commit 25fa95e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/antlr/listener/DefaultValueParserListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public void exitDefaultValue(boolean skipIfUnknownOptional) {
9595
}
9696

9797
private String unquote(String stringLiteral) {
98-
if (stringLiteral != null && stringLiteral.startsWith("'") && stringLiteral.endsWith("'")) {
98+
if (stringLiteral != null
99+
&& ((stringLiteral.startsWith("'") && stringLiteral.endsWith("'"))
100+
|| (stringLiteral.startsWith("\"") && stringLiteral.endsWith("\"")))) {
99101
return stringLiteral.substring(1, stringLiteral.length() - 1);
100102
}
101103
return stringLiteral;

flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlConnectorITCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ void testDdlWithDefaultStringValue() throws Exception {
15141514
+ " double_c DOUBLE DEFAULT ' 25',\n"
15151515
+ " double_un_c DOUBLE UNSIGNED DEFAULT ' 26',\n"
15161516
+ " double_un_z_c DOUBLE UNSIGNED ZEROFILL DEFAULT ' 27',\n"
1517-
+ " tiny_un_c TINYINT UNSIGNED DEFAULT ' 28 '"
1517+
+ " tiny_un_c TINYINT UNSIGNED DEFAULT \" 28 \""
15181518
+ " );");
15191519
}
15201520
actualRows.addAll(fetchRows(iterator, expected.length - 2));

0 commit comments

Comments
 (0)