diff --git a/server/controller/src/main/java/ai/starwhale/mlops/domain/report/mapper/ReportMapper.java b/server/controller/src/main/java/ai/starwhale/mlops/domain/report/mapper/ReportMapper.java index e5b9762be1..43df7a18be 100644 --- a/server/controller/src/main/java/ai/starwhale/mlops/domain/report/mapper/ReportMapper.java +++ b/server/controller/src/main/java/ai/starwhale/mlops/domain/report/mapper/ReportMapper.java @@ -51,7 +51,7 @@ public interface ReportMapper { @Select("SELECT " + COLUMNS_FOR_SELECT + " FROM report WHERE uuid = #{uuid}") ReportEntity selectByUuid(@Param("uuid") String uuid); - @Select("SELECT " + COLUMNS_FOR_SELECT + " FROM report WHERE uuid = #{uuid} FOR UPDATE") + @Select("SELECT " + COLUMNS_FOR_SELECT + " FROM report WHERE deleted_time = 0 and uuid = #{uuid} FOR UPDATE") ReportEntity selectByUuidForUpdate(@Param("uuid") String uuid); @Update("UPDATE report SET shared = #{shared} where id = #{id}") diff --git a/server/controller/src/test/java/ai/starwhale/mlops/domain/report/ReportMapperTest.java b/server/controller/src/test/java/ai/starwhale/mlops/domain/report/ReportMapperTest.java index acfb368663..1c91154790 100644 --- a/server/controller/src/test/java/ai/starwhale/mlops/domain/report/ReportMapperTest.java +++ b/server/controller/src/test/java/ai/starwhale/mlops/domain/report/ReportMapperTest.java @@ -17,6 +17,8 @@ package ai.starwhale.mlops.domain.report; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import ai.starwhale.mlops.domain.MySqlContainerHolder; @@ -83,10 +85,12 @@ public void test() { mapper.remove(entity.getId()); list = mapper.selectByProject("", 1L); assertEquals(0, list.size()); + assertNull(mapper.selectByUuidForUpdate(entity.getUuid())); mapper.recover(entity.getId()); list = mapper.selectByProject("", 1L); assertEquals(1, list.size()); + assertNotNull(mapper.selectByUuidForUpdate(entity.getUuid())); // filter list = mapper.selectByProject("title", 1L);