From 8028406e5a6d70abb39de3a4b40700d4d5a45045 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Fri, 26 Apr 2024 15:43:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86=E6=9C=89=E6=95=88=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E9=87=8D=E6=96=B0=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/provider/CalciteProvider.java | 17 +++++++++++++++++ .../datasource/server/DatasourceServer.java | 4 +--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java index c2ba23854f..69f8a9e196 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java @@ -981,6 +981,23 @@ public class CalciteProvider { } } + public void updateDsPoolAfterCheckStatus(DatasourceDTO datasourceDTO) throws DEException { + DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); + BeanUtils.copyBean(datasourceSchemaDTO, datasourceDTO); + datasourceSchemaDTO.setSchemaAlias(String.format(SQLConstants.SCHEMA, datasourceSchemaDTO.getId())); + DatasourceRequest datasourceRequest = new DatasourceRequest(); + datasourceRequest.setDsList(Map.of(datasourceSchemaDTO.getId(), datasourceSchemaDTO)); + try { + CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class); + SchemaPlus rootSchema = calciteConnection.getRootSchema(); + if (rootSchema.getSubSchema(datasourceSchemaDTO.getSchemaAlias()) == null) { + buildSchema(datasourceRequest, calciteConnection); + } + } catch (Exception e) { + DEException.throwException(e.getMessage()); + } + } + public void delete(CoreDatasource datasource) throws DEException { DatasourceSchemaDTO datasourceSchemaDTO = new DatasourceSchemaDTO(); BeanUtils.copyBean(datasourceSchemaDTO, datasource); diff --git a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java index 05923ea7d3..eb7b13104c 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java @@ -655,9 +655,7 @@ public class DatasourceServer implements DatasourceApi { BeanUtils.copyBean(datasourceDTO, coreDatasource); try { checkDatasourceStatus(coreDatasource); - if(StringUtils.isNotEmpty(lastStatus) && StringUtils.isNotEmpty(coreDatasource.getStatus()) && lastStatus.equalsIgnoreCase("Error") && coreDatasource.getStatus().equalsIgnoreCase("Success")){ - calciteProvider.update(datasourceDTO); - } + calciteProvider.updateDsPoolAfterCheckStatus(datasourceDTO); } catch (Exception e) { coreDatasource.setStatus("Error"); DEException.throwException(e.getMessage());