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 95811eb715..ed54708c2a 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 @@ -148,7 +148,19 @@ public class SqlparserUtils { return sql; } - + private static boolean isParams(String paramId){ + boolean isLong = false; + try { + Long.valueOf(paramId); + isLong = true; + }catch (Exception e){ + isLong = false; + } + if(paramId.length() >= 18 && isLong){ + return true; + } + return false; + } private String removeVariables(final String sql, String dsType) throws Exception { String tmpSql = sql.replaceAll("(?m)^\\s*$[\n\r]{0,}", ""); Pattern pattern = Pattern.compile(regex); @@ -165,6 +177,10 @@ public class SqlparserUtils { pattern = Pattern.compile(regex2); matcher = pattern.matcher(tmpSql); while (matcher.find()) { + String paramId = matcher.group().substring(1, matcher.group().length() - 1); + if(!isParams(paramId)){ + continue; + } hasVariables = true; tmpSql = tmpSql.replace(matcher.group(), SubstitutedParams); } @@ -172,6 +188,10 @@ public class SqlparserUtils { pattern = Pattern.compile(regex2); matcher = pattern.matcher(tmpSql); while (matcher.find()) { + String paramId = matcher.group().substring(1, matcher.group().length() - 1); + if(!isParams(paramId)){ + continue; + } hasVariables = true; tmpSql = tmpSql.replace(matcher.group(), SysParamsSubstitutedParams + matcher.group().substring(1, matcher.group().length() - 1)); Map sysParam = new HashMap<>(); diff --git a/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue b/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue index 7cc863305b..edd956a279 100644 --- a/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue +++ b/core/core-frontend/src/views/visualized/data/dataset/form/AddSql.vue @@ -203,6 +203,8 @@ const insertFieldToCodeMirror = (value: string) => { const setNameIdTrans = (from, to, originName, name2Auto?: string[]) => { let name2Id = originName + const ids = [...builtInList.value, ...fieldFormList.value].map(item => item.id) + const names = [...builtInList.value, ...fieldFormList.value].map(item => item.name) const nameIdMap = [...builtInList.value, ...fieldFormList.value].reduce((pre, next) => { pre[next[from]] = next[to] return pre @@ -214,7 +216,12 @@ const setNameIdTrans = (from, to, originName, name2Auto?: string[]) => { if (name2Auto) { name2Auto.push(nameIdMap[ele]) } - name2Id = name2Id.replace(`[${ele}]`, `[${nameIdMap[ele]}]`) + if (from === 'id' && ids.includes(ele)) { + name2Id = name2Id.replace(`[${ele}]`, `[${nameIdMap[ele]}]`) + } + if (from === 'name' && names.includes(ele)) { + name2Id = name2Id.replace(`[${ele}]`, `[${nameIdMap[ele]}]`) + } }) } return name2Id