feat: 添加sql数据集时,非空校验

This commit is contained in:
taojinlong 2021-06-02 16:58:37 +08:00
parent 1255d33d35
commit 047abdde1c
4 changed files with 9 additions and 3 deletions

View File

@ -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<TableFiled> previewFields = datasourceProvider.fetchResultField(datasourceRequest);
// 正式执行

View File

@ -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.
i18n_not_find_user=Can not find user.
i18n_sql_not_empty=SQL can not be empty.

View File

@ -246,4 +246,5 @@ i18n_username_exists=用户 ID 已存在
i18n_ds_name_exists=数据源名称已存在
i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息
i18n_not_find_user=未找到用户
i18n_not_find_user=未找到用户
i18n_sql_not_empty=SQL 不能为空

View File

@ -246,4 +246,5 @@ i18n_username_exists=用戶ID已存在
i18n_ds_name_exists=數據源名稱已存在
i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息
i18n_not_find_user=未找到用戶
i18n_not_find_user=未找到用戶
i18n_sql_not_empty=SQL 不能為空