fixed: 修复 QueryWrapper 不能使用超过一次; github close #49

This commit is contained in:
开源海哥 2023-06-08 11:14:23 +08:00
parent 19ca5f9373
commit 4b1ddae7bd

View File

@ -542,6 +542,7 @@ public interface BaseMapper<T> {
*/
default long selectCountByQuery(QueryWrapper queryWrapper) {
List<QueryColumn> selectColumns = CPI.getSelectColumns(queryWrapper);
try {
if (CollectionUtil.isEmpty(selectColumns)) {
queryWrapper.select(count());
}
@ -554,6 +555,10 @@ public interface BaseMapper<T> {
} else {
throw FlexExceptions.wrap("selectCountByQuery error, Can not get number value for queryWrapper: %s", queryWrapper);
}
} finally {
//fixed https://github.com/mybatis-flex/mybatis-flex/issues/49
CPI.setSelectColumns(queryWrapper, selectColumns);
}
}