From 4721c55dc0ba72f5231d48631907b3e1242da06f Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sun, 9 Oct 2022 14:19:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E9=9B=86):=20sql=20?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=94=AF=E6=8C=81=20union?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 457d498e67..5822c8631b 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1068,8 +1068,23 @@ public class DataSetTableService { CCJSqlParserUtil.parse(sql, parser -> parser.withSquareBracketQuotation(true)); Statement statement = CCJSqlParserUtil.parse(sql); Select select = (Select) statement; - PlainSelect plainSelect = ((PlainSelect) select.getSelectBody()); - // 访问from + + if (select.getSelectBody() instanceof PlainSelect) { + return handlePlainSelect((PlainSelect) select.getSelectBody(), select, dsType); + }else { + String result = ""; + SetOperationList setOperationList = (SetOperationList) select.getSelectBody(); + for (int i = 0; i < setOperationList.getSelects().size(); i++) { + result = result + handlePlainSelect((PlainSelect) setOperationList.getSelects().get(i), null, dsType); + if (i < setOperationList.getSelects().size() - 1) { + result = result + " " + setOperationList.getOperations().get(i).toString() + " "; + } + } + return result; + } + } + + private String handlePlainSelect(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception { FromItem fromItem = plainSelect.getFromItem(); if (fromItem instanceof SubSelect) { SelectBody selectBody = ((SubSelect) fromItem).getSelectBody(); @@ -1086,7 +1101,7 @@ public class DataSetTableService { } Expression expr = plainSelect.getWhere(); if (expr == null) { - return handleWith(plainSelect, select, dsType); + return handleWith(plainSelect, statementSelect, dsType); } StringBuilder stringBuilder = new StringBuilder(); BinaryExpression binaryExpression = null; @@ -1100,12 +1115,12 @@ public class DataSetTableService { expr.accept(getExpressionDeParser(stringBuilder)); } plainSelect.setWhere(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString())); - return handleWith(plainSelect, select, dsType); + return handleWith(plainSelect, statementSelect, dsType); } private String handleWith(PlainSelect plainSelect, Select select, String dsType) throws Exception { StringBuilder builder = new StringBuilder(); - if (CollectionUtils.isNotEmpty(select.getWithItemsList())) { + if (select != null && CollectionUtils.isNotEmpty(select.getWithItemsList())) { builder.append("WITH"); builder.append(" "); for (Iterator iter = select.getWithItemsList().iterator(); iter.hasNext(); ) { From 5510b1d732f47f0f81878115b1d707948be73a66 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Sun, 9 Oct 2022 17:43:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BB=84=E4=BB=B6=E5=92=8C=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E8=A7=86=E5=9B=BE=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E7=BC=A9=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/custom-component/DeRichText.vue | 29 +++- .../custom-component/DeRichTextView.vue | 135 ++++++++++-------- .../canvas/custom-component/UserView.vue | 1 + 3 files changed, 105 insertions(+), 60 deletions(-) diff --git a/frontend/src/components/canvas/custom-component/DeRichText.vue b/frontend/src/components/canvas/custom-component/DeRichText.vue index 97798dc30d..ed115ae0c9 100644 --- a/frontend/src/components/canvas/custom-component/DeRichText.vue +++ b/frontend/src/components/canvas/custom-component/DeRichText.vue @@ -1,5 +1,5 @@