mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
test: 测试使用 UpdateWrapper 插入子查询。
This commit is contained in:
parent
4e188b5cf6
commit
9fa4ed8633
@ -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<Account> wrapper = (UpdateWrapper<Account>) 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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user