Skip to content

Commit

Permalink
fix: 自定义sql中出现count(*)等函数导致数据查询异常bug修复;doris查询 排序 过滤冲突sql修复
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaJunjie2020 committed Jun 30, 2021
1 parent 3d2d187 commit 1248188
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartView
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
filter.append("%").append(f.getValue()).append("%");
} else {
filter.append("'" + f.getValue() + "'");
filter.append("'").append(f.getValue()).append("'");
}
return filter.toString();
}).toArray(String[]::new);
Expand Down Expand Up @@ -225,7 +225,7 @@ public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartView
} else if (StringUtils.containsIgnoreCase(f.getTerm(), "like")) {
filter.append("%").append(f.getValue()).append("%");
} else {
filter.append("'" + f.getValue() + "'");
filter.append("'").append(f.getValue()).append("'");
}
return filter.toString();
}).toArray(String[]::new);
Expand All @@ -234,9 +234,10 @@ public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartView
if (resultFilter.length == 0) {
return sql;
} else {
String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1}",
String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1} ORDER BY {2}",
"(" + sql + ") AS tmp",
StringUtils.join(resultFilter, " "));
StringUtils.join(resultFilter, " "),
StringUtils.join(yOrder, ","));
return filterSql;
}
}
Expand Down Expand Up @@ -314,9 +315,10 @@ public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<Ch
if (resultFilter.length == 0) {
return sql;
} else {
String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1}",
String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1} ORDER BY {2}",
"(" + sql + ") AS tmp",
StringUtils.join(resultFilter, " "));
StringUtils.join(resultFilter, " "),
StringUtils.join(order, ","));
return filterSql;
}
}
Expand Down

0 comments on commit 1248188

Please sign in to comment.