提交 047abdde authored 作者: taojinlong's avatar taojinlong

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

上级 1255d33d
......@@ -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);
// 正式执行
......
......@@ -245,3 +245,4 @@ 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_sql_not_empty=SQL can not be empty.
\ No newline at end of file
......@@ -247,3 +247,4 @@ i18n_ds_name_exists=数据源名称已存在
i18n_sync_job_exists=已经有同步任务在运行,稍后重试
i18n_datasource_check_fail=校验失败,请检查配置信息
i18n_not_find_user=未找到用户
i18n_sql_not_empty=SQL 不能为空
\ No newline at end of file
......@@ -247,3 +247,4 @@ i18n_ds_name_exists=數據源名稱已存在
i18n_sync_job_exists=已經有同步任務在運行,稍後重試
i18n_datasource_check_fail=校驗失敗,請檢查配置信息
i18n_not_find_user=未找到用戶
i18n_sql_not_empty=SQL 不能為空
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论