diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java index c0fa15c2..5043cb10 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java @@ -17,8 +17,11 @@ package com.mybatisflex.test.mapper; import com.mybatisflex.core.logicdelete.LogicDeleteManager; +import com.mybatisflex.core.query.QueryMethods; import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.row.Db; +import com.mybatisflex.core.update.UpdateWrapper; +import com.mybatisflex.core.util.UpdateEntity; import com.mybatisflex.test.model.Account; import com.mybatisflex.test.model.AccountVO; import com.mybatisflex.test.model.AccountVO2; @@ -26,6 +29,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.UncategorizedSQLException; import java.util.Date; @@ -48,6 +52,21 @@ class AccountMapperTest { @Autowired private AccountMapper accountMapper; + @Test + void testInsertRaw() { + Account account = UpdateEntity.of(Account.class); + account.setUserName("I'm a joker."); + account.setBirthday(new Date()); + UpdateWrapper wrapper = (UpdateWrapper) account; + QueryWrapper queryWrapper = QueryWrapper.create() + .select(ACCOUNT.AGE) + .from(ACCOUNT) + .where(ACCOUNT.ID.eq(1)); + wrapper.set(ACCOUNT.AGE, queryWrapper); + wrapper.set(ACCOUNT.BIRTHDAY, QueryMethods.now()); + Assertions.assertThrows(UncategorizedSQLException.class, () -> accountMapper.insert(account)); + } + @Test void testCount() { QueryWrapper queryWrapper = QueryWrapper.create()