mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
test: 测试 QueryCondition#when 方法。
This commit is contained in:
parent
bfe552b7db
commit
dbc6e79a58
@ -19,6 +19,9 @@ package com.mybatisflex.coretest;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
||||
|
||||
/**
|
||||
@ -40,4 +43,17 @@ public class DynamicConditionTest {
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test02() {
|
||||
List<Integer> idList = Arrays.asList(1, 2, 3);
|
||||
|
||||
String sql = QueryWrapper.create()
|
||||
.from(ACCOUNT)
|
||||
.where(ACCOUNT.ID.in(idList).when(false))
|
||||
.where(ACCOUNT.ID.in(idList).when(() -> !idList.isEmpty()))
|
||||
.toSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user