fix(数据集): 修复SQL片段分号结尾后有空格、换行符报错的问题

This commit is contained in:
junjun 2024-08-23 10:41:01 +08:00
parent c721ebc124
commit 2ce4249c8e
3 changed files with 9 additions and 6 deletions

View File

@ -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)) {

View File

@ -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);

View File

@ -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 =