forked from github/dataease
Merge pull request #4886 from dataease/pr@dev@fixextratdata
fix: 解析sql 错误
This commit is contained in:
commit
4b6158ec35
@ -147,7 +147,7 @@ public class DataSetTableService {
|
|||||||
public static final String regex = "\\$\\{(.*?)\\}";
|
public static final String regex = "\\$\\{(.*?)\\}";
|
||||||
private static final String SubstitutedParams = "DATAEASE_PATAMS_BI";
|
private static final String SubstitutedParams = "DATAEASE_PATAMS_BI";
|
||||||
private static final String SubstitutedSql = " 'BI' = 'BI' ";
|
private static final String SubstitutedSql = " 'BI' = 'BI' ";
|
||||||
private static final String SubstitutedSqlVirtualData = " 1 < 2 ";
|
private static final String SubstitutedSqlVirtualData = " 1 > 2 ";
|
||||||
|
|
||||||
@Value("${upload.file.path}")
|
@Value("${upload.file.path}")
|
||||||
private String path;
|
private String path;
|
||||||
@ -1272,7 +1272,7 @@ public class DataSetTableService {
|
|||||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||||
datasourceRequest.setDatasource(ds);
|
datasourceRequest.setDatasource(ds);
|
||||||
|
|
||||||
sql = realData ? handleVariableDefaultValue(sql, dataSetTableRequest.getSqlVariableDetails(), ds.getType(), true) : removeVariables(sql, ds.getType()).replaceAll(SubstitutedSql, SubstitutedSqlVirtualData);
|
sql = realData ? handleVariableDefaultValue(sql, dataSetTableRequest.getSqlVariableDetails(), ds.getType(), true) : removeVariables(sql, ds.getType()).replaceAll(SubstitutedSql.trim(), SubstitutedSqlVirtualData);
|
||||||
if (StringUtils.isEmpty(sql)) {
|
if (StringUtils.isEmpty(sql)) {
|
||||||
DataEaseException.throwException(Translator.get("i18n_sql_not_empty"));
|
DataEaseException.throwException(Translator.get("i18n_sql_not_empty"));
|
||||||
}
|
}
|
||||||
@ -1942,7 +1942,7 @@ public class DataSetTableService {
|
|||||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||||
DataTableInfoDTO dataTableInfo = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
DataTableInfoDTO dataTableInfo = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class);
|
||||||
String sql = dataTableInfo.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfo.getSql())) : dataTableInfo.getSql();
|
String sql = dataTableInfo.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfo.getSql())) : dataTableInfo.getSql();
|
||||||
sql = removeVariables(sql, ds.getType()).replaceAll(SubstitutedSql, SubstitutedSqlVirtualData);
|
sql = removeVariables(sql, ds.getType()).replaceAll(SubstitutedSql.trim(), SubstitutedSqlVirtualData);
|
||||||
String sqlAsTable = qp.createSQLPreview(sql, null);
|
String sqlAsTable = qp.createSQLPreview(sql, null);
|
||||||
datasourceRequest.setQuery(sqlAsTable);
|
datasourceRequest.setQuery(sqlAsTable);
|
||||||
fields = datasourceProvider.fetchResultField(datasourceRequest);
|
fields = datasourceProvider.fetchResultField(datasourceRequest);
|
||||||
|
Loading…
Reference in New Issue
Block a user