From 18d1ac83566639784dd3a71adf341b00e7d7edb8 Mon Sep 17 00:00:00 2001 From: lbw Date: Tue, 25 Jul 2023 19:41:14 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fixing=20a=20bug.=20#5025=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=20COUNT=20=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=9C=A8=E5=85=A8=E9=83=A8=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E6=89=A7=E8=A1=8C=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datascope/DataScopeInnerInterceptor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java index 0e889b87e..c355d20d0 100644 --- a/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java +++ b/pigx-common/pigx-common-data/src/main/java/com/pig4cloud/pigx/common/data/datascope/DataScopeInnerInterceptor.java @@ -37,8 +37,15 @@ public class DataScopeInnerInterceptor implements DataScopeInterceptor { return; } - // 返回true 不拦截直接返回原始 SQL - if (dataScopeHandle.calcScope(dataScope)) { + // 返回true 不拦截直接返回原始 SQL (只针对 * 查询) + if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.ALL.equals(dataScope.getFunc())) { + return; + } + + // 返回true 不拦截直接返回原始 SQL (只针对 COUNT 查询) + if (dataScopeHandle.calcScope(dataScope) && DataScopeFuncEnum.COUNT.equals(dataScope.getFunc())) { + mpBs.sql(String.format("SELECT %s FROM (%s) temp_data_scope", + dataScope.getFunc().getType(), originalSql)); return; }