fix: 修复两个 NPE 问题。

This commit is contained in:
Suomm 2023-07-04 10:47:30 +08:00
parent e903b9ed0f
commit faaa7247bf

View File

@ -316,6 +316,11 @@ public class CommonsDialectImpl implements IDialect {
@Override
public String buildSelectSql(QueryWrapper queryWrapper) {
List<QueryTable> queryTables = CPI.getQueryTables(queryWrapper);
if (CollectionUtil.isEmpty(queryTables)) {
throw FlexExceptions.wrap("You must use the 'FROM' clause to select the table.");
}
List<QueryTable> joinTables = CPI.getJoinTables(queryWrapper);
List<QueryTable> allTables = CollectionUtil.merge(queryTables, joinTables);
@ -332,6 +337,11 @@ public class CommonsDialectImpl implements IDialect {
QueryColumn selectColumn = selectColumns.get(i);
QueryTable selectColumnTable = selectColumn.getTable();
// function 等没有对应的 selectColumnTable
if (selectColumnTable == null) {
continue;
}
//用户未配置别名的情况下自动未用户添加别名
if (StringUtil.isBlank(selectColumn.getAlias())
&& !(selectColumnTable instanceof SelectQueryTable)