From 80f78b0db2f05caf701049de6d8507a5ef60e2a3 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 25 Mar 2025 00:05:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=9B=BF=E6=8D=A2=E9=94=99=E8=AF=AF=20(#1547?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: taojinlong --- .../java/io/dataease/commons/utils/SqlparserUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 d220458569..1d5754a447 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 @@ -47,6 +47,7 @@ public class SqlparserUtils { private static final String SysParamsSubstitutedParams = "DeSysParams_"; private static final String SubstitutedSql = " 'DE-BI' = 'DE-BI' "; private boolean removeSysParams; + boolean hasVariables = false; private UserFormVO userEntity; private final List> sysParams = new ArrayList<>(); @@ -62,6 +63,7 @@ public class SqlparserUtils { } catch (Exception e) { DEException.throwException(e); } + hasVariables = false; sql = sql.trim(); if (sql.endsWith(";")) { sql = sql.substring(0, sql.length() - 1); @@ -149,6 +151,9 @@ public class SqlparserUtils { } private static boolean isParams(String paramId){ + if(Arrays.asList("userId", "userEmail", "userName").contains(paramId)){ + return true; + } boolean isLong = false; try { Long.valueOf(paramId); @@ -165,14 +170,13 @@ public class SqlparserUtils { String tmpSql = sql.replaceAll("(?m)^\\s*$[\n\r]{0,}", ""); Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(tmpSql); - boolean hasVariables = false; while (matcher.find()) { hasVariables = true; tmpSql = tmpSql.replace(matcher.group(), SubstitutedParams); } if (removeSysParams) { for (Map sysParam : sysParams) { - tmpSql = tmpSql.replaceAll(sysParam.get("replace"), sysParam.get("origin")); + tmpSql = tmpSql.replace(sysParam.get("replace"), sysParam.get("origin")); } pattern = Pattern.compile(regex2); matcher = pattern.matcher(tmpSql);