Skip to content

Commit

Permalink
[bugfix] fix pgsql create table comment special string bug (#7022)
Browse files Browse the repository at this point in the history
  • Loading branch information
chl-wxp authored Jun 20, 2024
1 parent fa350f0 commit 9fe844f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private String buildColumnCommentSql(Column column, String tableName) {
columnCommentSql
.append(CatalogUtils.quoteIdentifier(column.getName(), fieldIde, "\""))
.append(CatalogUtils.quoteIdentifier(" IS '", fieldIde))
.append(column.getComment())
.append(column.getComment().replace("'", "''"))
.append("'");
return columnCommentSql.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class JdbcPostgresIT extends TestSuiteBase implements TestResource {
+ " json_col json NOT NULL,\n"
+ " jsonb_col jsonb NOT NULL,\n"
+ " xml_col xml NOT NULL\n"
+ ")";
+ ");comment on column pg_e2e_source_table.uuid_col is '\"#¥%……&*();;'',,.\\.``````//''@特殊注释''\\\\''\"'";
private static final String PG_SINK_DDL =
"CREATE TABLE IF NOT EXISTS pg_e2e_sink_table (\n"
+ " gid SERIAL PRIMARY KEY,\n"
Expand Down Expand Up @@ -482,6 +482,11 @@ public void testCatalogForSaveMode() {
postgresCatalog.createTable(tablePathPgSink, catalogTable, true);
boolean tableExistsAfter = postgresCatalog.tableExists(tablePathPgSink);
Assertions.assertTrue(tableExistsAfter);
// comment
final CatalogTable table = postgresCatalog.getTable(tablePathPgSink);
Assertions.assertEquals(
table.getTableSchema().getColumns().get(1).getComment(),
"\"#¥%……&*();;',,.\\.``````//'@特殊注释'\\\\'\"");
// isExistsData ?
boolean existsDataBefore = postgresCatalog.isExistsData(tablePathPgSink);
Assertions.assertFalse(existsDataBefore);
Expand Down

0 comments on commit 9fe844f

Please sign in to comment.