From 6bb3dd998bd8f48d375971320039bdd6edbdde1a Mon Sep 17 00:00:00 2001 From: tjlygdx Date: Tue, 16 Jun 2026 15:20:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=BC=8F=E6=B4=9E=E3=80=91?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=93=8D=E7=BA=B5=E3=80=81=E6=95=8F=E6=84=9F?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=B3=84=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/dataset/utils/TableUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/core-backend/src/main/java/io/dataease/dataset/utils/TableUtils.java b/core/core-backend/src/main/java/io/dataease/dataset/utils/TableUtils.java index 2f9f7438fe..7e641c124a 100644 --- a/core/core-backend/src/main/java/io/dataease/dataset/utils/TableUtils.java +++ b/core/core-backend/src/main/java/io/dataease/dataset/utils/TableUtils.java @@ -101,4 +101,24 @@ public class TableUtils { .map(part -> quoteIdentifier(part, prefix, suffix)) .collect(Collectors.joining(".")); } + + public static String quoteIdentifier(String name, String prefix, String suffix) { + String resolvedPrefix = StringUtils.defaultString(prefix); + String resolvedSuffix = StringUtils.defaultString(suffix); + if (StringUtils.isEmpty(resolvedPrefix) && StringUtils.isEmpty(resolvedSuffix)) { + resolvedPrefix = Quoting.BACK_TICK.string; + resolvedSuffix = Quoting.BACK_TICK.string; + } + String escapedName = StringUtils.defaultString(name); + if (StringUtils.isNotEmpty(resolvedSuffix)) { + escapedName = escapedName.replace(resolvedSuffix, resolvedSuffix + resolvedSuffix); + } + return resolvedPrefix + escapedName + resolvedSuffix; + } + + public static String quoteCompoundIdentifier(String name, String prefix, String suffix) { + return Arrays.stream(StringUtils.defaultString(name).split("\\.", -1)) + .map(part -> quoteIdentifier(part, prefix, suffix)) + .collect(Collectors.joining(".")); + } }