From 2ce4249c8e87423c660e3ec26fb6fa817adae43c Mon Sep 17 00:00:00 2001 From: junjun Date: Fri, 23 Aug 2024 10:41:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E9=9B=86):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DSQL=E7=89=87=E6=AE=B5=E5=88=86=E5=8F=B7=E7=BB=93?= =?UTF-8?q?=E5=B0=BE=E5=90=8E=E6=9C=89=E7=A9=BA=E6=A0=BC=E3=80=81=E6=8D=A2?= =?UTF-8?q?=E8=A1=8C=E7=AC=A6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/dataease/commons/utils/SqlparserUtils.java | 5 +++-- .../main/java/io/dataease/copilot/manage/CopilotManage.java | 5 +++-- .../src/main/java/io/dataease/dataset/utils/SqlUtils.java | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java index 7a75eb6655..463019f503 100644 --- a/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java +++ b/core/core-backend/src/main/java/io/dataease/commons/utils/SqlparserUtils.java @@ -481,8 +481,9 @@ public class SqlparserUtils { if (StringUtils.isEmpty(sql)) { DEException.throwException(Translator.get("i18n_sql_not_empty")); } - if (sql.trim().endsWith(";")) { - sql = sql.trim().substring(0, sql.length() - 1); + sql = sql.trim(); + if (sql.endsWith(";")) { + sql = sql.substring(0, sql.length() - 1); } if (StringUtils.isNotEmpty(sqlVariableDetails)) { diff --git a/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java b/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java index eb2249e805..958547586f 100644 --- a/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java +++ b/core/core-backend/src/main/java/io/dataease/copilot/manage/CopilotManage.java @@ -450,8 +450,9 @@ public class CopilotManage { public String transSql(String type, String copilotSQL, Provider provider, ReceiveDTO receiveDTO) { if (type.equals("oracle") || type.equals("sqlServer")) { try { - if (copilotSQL.trim().endsWith(";")) { - copilotSQL = copilotSQL.trim().substring(0, copilotSQL.length() - 1); + copilotSQL = copilotSQL.trim(); + if (copilotSQL.endsWith(";")) { + copilotSQL = copilotSQL.substring(0, copilotSQL.length() - 1); } DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); datasourceSchemaDTO.setType(type); diff --git a/core/core-backend/src/main/java/io/dataease/dataset/utils/SqlUtils.java b/core/core-backend/src/main/java/io/dataease/dataset/utils/SqlUtils.java index 16a33ae44c..e7749dd092 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/utils/SqlUtils.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/utils/SqlUtils.java @@ -20,8 +20,9 @@ public class SqlUtils { public static Logger logger = LoggerFactory.getLogger(SqlUtils.class); public static String addSchema(String sql, String schema) { - if (sql.trim().endsWith(";")) { - sql = sql.trim().substring(0, sql.length() - 1); + sql = sql.trim(); + if (sql.endsWith(";")) { + sql = sql.substring(0, sql.length() - 1); } SqlParser.Config config =