test: 测试 QueryWrapper 传入 null 值。

This commit is contained in:
Suomm 2023-06-21 19:01:58 +08:00
parent af85476c82
commit 996310456c
3 changed files with 30 additions and 1 deletions

View File

@ -16,6 +16,8 @@
package com.mybatisflex.test.model;
import com.mybatisflex.annotation.Column;
import java.util.List;
/**
@ -25,6 +27,7 @@ import java.util.List;
public class BaseEntity<T, ID, L> extends IdEntity<ID> {
protected T userName;
@Column(ignore = true)
protected List<L> roles;
public List<L> getRoles() {

View File

@ -4,7 +4,7 @@ spring:
# console:
# enabled: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/flex_test
username: root
password: 12345678

View File

@ -17,14 +17,18 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.test.model.Account;
import com.mybatisflex.test.model.AccountVO;
import com.mybatisflex.test.model.Gender;
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 java.util.Date;
import java.util.List;
import static com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT;
import static com.mybatisflex.test.model.table.RoleTableDef.ROLE;
@ -86,4 +90,26 @@ class AccountMapperTest {
accountMapper.update(account);
}
@Test
void testSelectList() {
List<Account> accounts = accountMapper.selectListByQuery(null);
System.out.println(accounts);
List<Row> account = Db.selectListByQuery("tb_account", null);
System.out.println(account);
}
@Test
void testUpdateAll() {
Account account = new Account();
account.setAge(10);
Assertions.assertThrows(Exception.class, () ->
accountMapper.updateByQuery(account, QueryWrapper.create()));
}
@Test
void testDeleteAll() {
Assertions.assertThrows(Exception.class, () ->
accountMapper.deleteByQuery(QueryWrapper.create()));
}
}