forked from github/dataease
Merge pull request #12811 from dataease/pr@dev-v2@fix_ds
fix(数据源): 修复SQL Server参数化无法过滤中文的问题
This commit is contained in:
commit
642d839bed
@ -536,7 +536,7 @@ public class SqlparserUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filterParameter != null) {
|
if (filterParameter != null) {
|
||||||
sql = sql.replace(matcher.group(), transFilter(filterParameter));
|
sql = sql.replace(matcher.group(), transFilter(filterParameter, dsMap));
|
||||||
} else {
|
} else {
|
||||||
if (defaultsSqlVariableDetail != null && StringUtils.isNotEmpty(defaultsSqlVariableDetail.getDefaultValue())) {
|
if (defaultsSqlVariableDetail != null && StringUtils.isNotEmpty(defaultsSqlVariableDetail.getDefaultValue())) {
|
||||||
if (!isEdit && isFromDataSet && defaultsSqlVariableDetail.getDefaultValueScope().equals(SqlVariableDetails.DefaultValueScope.ALLSCOPE)) {
|
if (!isEdit && isFromDataSet && defaultsSqlVariableDetail.getDefaultValueScope().equals(SqlVariableDetails.DefaultValueScope.ALLSCOPE)) {
|
||||||
@ -594,9 +594,14 @@ public class SqlparserUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String transFilter(SqlVariableDetails sqlVariableDetails) {
|
private static String transFilter(SqlVariableDetails sqlVariableDetails, Map<Long, DatasourceSchemaDTO> dsMap) {
|
||||||
if (sqlVariableDetails.getOperator().equals("in")) {
|
if (sqlVariableDetails.getOperator().equals("in")) {
|
||||||
|
if (StringUtils.equalsIgnoreCase(dsMap.entrySet().iterator().next().getValue().getType(), DatasourceConfiguration.DatasourceType.sqlServer.getType())
|
||||||
|
&& sqlVariableDetails.getDeType() == 0) {
|
||||||
|
return "N'" + String.join("', N'", sqlVariableDetails.getValue()) + "'";
|
||||||
|
} else {
|
||||||
return "'" + String.join("','", sqlVariableDetails.getValue()) + "'";
|
return "'" + String.join("','", sqlVariableDetails.getValue()) + "'";
|
||||||
|
}
|
||||||
} else if (sqlVariableDetails.getOperator().equals("between")) {
|
} else if (sqlVariableDetails.getOperator().equals("between")) {
|
||||||
if (sqlVariableDetails.getDeType() == 1) {
|
if (sqlVariableDetails.getDeType() == 1) {
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sqlVariableDetails.getType().size() > 1 ? (String) sqlVariableDetails.getType().get(1).replace("DD", "dd").replace("YYYY", "yyyy") : "yyyy");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sqlVariableDetails.getType().size() > 1 ? (String) sqlVariableDetails.getType().get(1).replace("DD", "dd").replace("YYYY", "yyyy") : "yyyy");
|
||||||
|
Loading…
Reference in New Issue
Block a user