update magic-api/src/main/java/org/ssssssss/magicapi/modules/db/table/NamedTable.java.

此处拼接sql语句时,当order by和group by 一起使用时,应当先分组再排序,sql语句错误
This commit is contained in:
cjn 2022-06-01 07:39:59 +00:00 committed by Gitee
parent 25fa9d0839
commit 17b571c2dd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -484,14 +484,14 @@ public class NamedTable extends Attributes<Object> {
}
builder.append(" from ").append(tableName);
List<Object> params = buildWhere(builder);
if (!groups.isEmpty()) {
builder.append(" group by ");
builder.append(String.join(",", groups));
}
if (!orders.isEmpty()) {
builder.append(" order by ");
builder.append(String.join(",", orders));
}
if (!groups.isEmpty()) {
builder.append(" group by ");
builder.append(String.join(",", groups));
}
BoundSql boundSql = new BoundSql(runtimeContext, builder.toString(), params, sqlModule);
boundSql.setExcludeColumns(excludeColumns);
return boundSql;