From 1943f0eb0bc77bc5ef7fdb9f21e5008b5b76569b Mon Sep 17 00:00:00 2001 From: Licho Date: Tue, 30 Jan 2024 22:50:10 +0800 Subject: [PATCH] fix: split problem (#3097) --- .../main/java/org/dinky/data/model/SystemConfiguration.java | 2 +- dinky-common/src/main/java/org/dinky/utils/SqlUtil.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java b/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java index edfe012927..f0474872b8 100644 --- a/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java +++ b/dinky-common/src/main/java/org/dinky/data/model/SystemConfiguration.java @@ -68,7 +68,7 @@ public static Configuration.OptionBuilder key(Status status) { .note(Status.SYS_FLINK_SETTINGS_USERESTAPI_NOTE); private final Configuration sqlSeparator = key(Status.SYS_FLINK_SETTINGS_SQLSEPARATOR) .stringType() - .defaultValue(";\\s*(?:\\n|--.*)") + .defaultValue(";\\n") .note(Status.SYS_FLINK_SETTINGS_SQLSEPARATOR_NOTE); private final Configuration jobIdWait = key(Status.SYS_FLINK_SETTINGS_JOBIDWAIT) .intType() diff --git a/dinky-common/src/main/java/org/dinky/utils/SqlUtil.java b/dinky-common/src/main/java/org/dinky/utils/SqlUtil.java index ba1b7e52d8..a83aa92439 100644 --- a/dinky-common/src/main/java/org/dinky/utils/SqlUtil.java +++ b/dinky-common/src/main/java/org/dinky/utils/SqlUtil.java @@ -45,7 +45,8 @@ public static String[] getStatements(String sql, String sqlSeparator) { return new String[0]; } - String[] splits = sql.replace("\r\n", "\n").split(sqlSeparator); + final String localSqlSeparator = ";\\s*(?:\\n|--.*)"; + String[] splits = sql.replace("\r\n", "\n").split(localSqlSeparator); String lastStatement = splits[splits.length - 1].trim(); if (lastStatement.endsWith(SEMICOLON)) { splits[splits.length - 1] = lastStatement.substring(0, lastStatement.length() - 1);