build: v1.8.0 release (^.^)YYa!!

This commit is contained in:
Michael Yang 2024-02-23 10:51:12 +08:00
parent 056d09adda
commit 03bb32c979
3 changed files with 24 additions and 11 deletions

View File

@ -3,7 +3,6 @@
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
## v1.8.0 20240223:
- 优化selectOneByQuery(QueryWrapper queryWrapper) 由用户主动添加 limit 1
- 优化entityOrBase.tpl 中命令占位符被替换后entity 里面多了一行空白行,感谢 @caohenghui
- 修复:在复杂的 VO 嵌套查询时addResultMap 抛出异常的问题,感谢 @leizhiyou
- 修复:实体类实现多层级的接口时监听器无法匹配问题,感谢 @ruansheng

View File

@ -433,7 +433,13 @@ public interface BaseMapper<T> {
* @return 实体类数据
*/
default T selectOneByQuery(QueryWrapper queryWrapper) {
Long limitRows = CPI.getLimitRows(queryWrapper);
try {
queryWrapper.limit(1);
return MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper));
} finally {
CPI.setLimitRows(queryWrapper, limitRows);
}
}
/**
@ -444,7 +450,13 @@ public interface BaseMapper<T> {
* @return 实体类数据
*/
default <R> R selectOneByQueryAs(QueryWrapper queryWrapper, Class<R> asType) {
Long limitRows = CPI.getLimitRows(queryWrapper);
try {
queryWrapper.limit(1);
return MapperUtil.getSelectOneResult(selectListByQueryAs(queryWrapper, asType));
} finally {
CPI.setLimitRows(queryWrapper, limitRows);
}
}
/**
@ -455,7 +467,7 @@ public interface BaseMapper<T> {
*/
default T selectOneWithRelationsByMap(Map<String, Object> whereConditions) {
FlexAssert.notEmpty(whereConditions, "whereConditions");
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions));
}
/**
@ -466,7 +478,7 @@ public interface BaseMapper<T> {
*/
default T selectOneWithRelationsByCondition(QueryCondition whereConditions) {
FlexAssert.notNull(whereConditions, "whereConditions");
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions).limit(1L));
return selectOneWithRelationsByQuery(QueryWrapper.create().where(whereConditions));
}
/**
@ -476,7 +488,13 @@ public interface BaseMapper<T> {
* @return 实体类数据
*/
default T selectOneWithRelationsByQuery(QueryWrapper queryWrapper) {
Long limitRows = CPI.getLimitRows(queryWrapper);
try {
queryWrapper.limit(1);
return MapperUtil.queryRelations(this, MapperUtil.getSelectOneResult(selectListByQuery(queryWrapper)));
} finally {
CPI.setLimitRows(queryWrapper, limitRows);
}
}
/**

View File

@ -82,11 +82,7 @@ public class Account6Test implements WithAssertions {
// 没有 ID插入失败
Assert.fail();
} catch (Exception e) {
assertThat(e.getCause()).isInstanceOf(InvocationTargetException.class)
.asInstanceOf(InstanceOfAssertFactories.type(InvocationTargetException.class))
.extracting(i -> i.getTargetException().getMessage())
.asString()
.contains("NULL not allowed for column \"ID\"");
Assert.assertTrue(e.getMessage().contains("NULL not allowed for column \"ID\""));
}
List<Account6> list = mapper.selectAll();