From 047abdde1c39c39ba2bb7c05a47a2c854af1ad69 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 2 Jun 2021 16:58:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0sql=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=97=B6=EF=BC=8C=E9=9D=9E=E7=A9=BA=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 3 +++ backend/src/main/resources/i18n/messages_en_US.properties | 3 ++- backend/src/main/resources/i18n/messages_zh_CN.properties | 3 ++- backend/src/main/resources/i18n/messages_zh_TW.properties | 3 ++- 4 files changed, 9 insertions(+), 3 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 45b4303c4f..a0f0555080 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -351,6 +351,9 @@ public class DataSetTableService { datasourceRequest.setDatasource(ds); String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql(); // 使用输入的sql先预执行一次,并拿到所有字段 + if(StringUtils.isEmpty(sql)){ + throw new Exception(Translator.get("i18n_sql_not_empty")); + } datasourceRequest.setQuery(sql); List previewFields = datasourceProvider.fetchResultField(datasourceRequest); // 正式执行 diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index b84486d115..0a378bdf4d 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -244,4 +244,5 @@ i18n_username_exists=ID is already exists i18n_ds_name_exists=Datasource name exists i18n_sync_job_exists=There is already a synchronization task running, please try again later i18n_datasource_check_fail=Invalid,please check config -i18n_not_find_user=Can not find user. \ No newline at end of file +i18n_not_find_user=Can not find user. +i18n_sql_not_empty=SQL can not be empty. \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 83339dfbfb..46259d26ec 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -246,4 +246,5 @@ i18n_username_exists=用户 ID 已存在 i18n_ds_name_exists=数据源名称已存在 i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_datasource_check_fail=校验失败,请检查配置信息 -i18n_not_find_user=未找到用户 \ No newline at end of file +i18n_not_find_user=未找到用户 +i18n_sql_not_empty=SQL 不能为空 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 228e7081b3..fd650136bf 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -246,4 +246,5 @@ i18n_username_exists=用戶ID已存在 i18n_ds_name_exists=數據源名稱已存在 i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_datasource_check_fail=校驗失敗,請檢查配置信息 -i18n_not_find_user=未找到用戶 \ No newline at end of file +i18n_not_find_user=未找到用戶 +i18n_sql_not_empty=SQL 不能為空 \ No newline at end of file