forked from github/dataease
fix(数据集): 修复SQL片段分号结尾后有空格、换行符报错的问题
This commit is contained in:
parent
c721ebc124
commit
2ce4249c8e
@ -481,8 +481,9 @@ public class SqlparserUtils {
|
|||||||
if (StringUtils.isEmpty(sql)) {
|
if (StringUtils.isEmpty(sql)) {
|
||||||
DEException.throwException(Translator.get("i18n_sql_not_empty"));
|
DEException.throwException(Translator.get("i18n_sql_not_empty"));
|
||||||
}
|
}
|
||||||
if (sql.trim().endsWith(";")) {
|
sql = sql.trim();
|
||||||
sql = sql.trim().substring(0, sql.length() - 1);
|
if (sql.endsWith(";")) {
|
||||||
|
sql = sql.substring(0, sql.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(sqlVariableDetails)) {
|
if (StringUtils.isNotEmpty(sqlVariableDetails)) {
|
||||||
|
@ -450,8 +450,9 @@ public class CopilotManage {
|
|||||||
public String transSql(String type, String copilotSQL, Provider provider, ReceiveDTO receiveDTO) {
|
public String transSql(String type, String copilotSQL, Provider provider, ReceiveDTO receiveDTO) {
|
||||||
if (type.equals("oracle") || type.equals("sqlServer")) {
|
if (type.equals("oracle") || type.equals("sqlServer")) {
|
||||||
try {
|
try {
|
||||||
if (copilotSQL.trim().endsWith(";")) {
|
copilotSQL = copilotSQL.trim();
|
||||||
copilotSQL = copilotSQL.trim().substring(0, copilotSQL.length() - 1);
|
if (copilotSQL.endsWith(";")) {
|
||||||
|
copilotSQL = copilotSQL.substring(0, copilotSQL.length() - 1);
|
||||||
}
|
}
|
||||||
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO();
|
||||||
datasourceSchemaDTO.setType(type);
|
datasourceSchemaDTO.setType(type);
|
||||||
|
@ -20,8 +20,9 @@ public class SqlUtils {
|
|||||||
public static Logger logger = LoggerFactory.getLogger(SqlUtils.class);
|
public static Logger logger = LoggerFactory.getLogger(SqlUtils.class);
|
||||||
|
|
||||||
public static String addSchema(String sql, String schema) {
|
public static String addSchema(String sql, String schema) {
|
||||||
if (sql.trim().endsWith(";")) {
|
sql = sql.trim();
|
||||||
sql = sql.trim().substring(0, sql.length() - 1);
|
if (sql.endsWith(";")) {
|
||||||
|
sql = sql.substring(0, sql.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlParser.Config config =
|
SqlParser.Config config =
|
||||||
|
Loading…
Reference in New Issue
Block a user