mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 17:48:25 +08:00
test: 动态条件构建测试。
This commit is contained in:
parent
b38131bf2c
commit
0e3898784d
@ -17,6 +17,8 @@
|
|||||||
package com.mybatisflex.coretest;
|
package com.mybatisflex.coretest;
|
||||||
|
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.core.util.CollectionUtil;
|
||||||
|
import com.mybatisflex.core.util.StringUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -50,7 +52,28 @@ public class DynamicConditionTest {
|
|||||||
String sql = QueryWrapper.create()
|
String sql = QueryWrapper.create()
|
||||||
.from(ACCOUNT)
|
.from(ACCOUNT)
|
||||||
.where(ACCOUNT.ID.in(idList).when(false))
|
.where(ACCOUNT.ID.in(idList).when(false))
|
||||||
.where(ACCOUNT.ID.in(idList).when(() -> !idList.isEmpty()))
|
.where(ACCOUNT.ID.in(idList, CollectionUtil::isNotEmpty))
|
||||||
|
.where(ACCOUNT.ID.in(idList).when(idList::isEmpty))
|
||||||
|
.toSQL();
|
||||||
|
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test03() {
|
||||||
|
String sql = QueryWrapper.create()
|
||||||
|
.from(ACCOUNT)
|
||||||
|
.where(ACCOUNT.ID.eq("1", StringUtil::isNumeric))
|
||||||
|
.toSQL();
|
||||||
|
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test04() {
|
||||||
|
String sql = QueryWrapper.create()
|
||||||
|
.from(ACCOUNT)
|
||||||
|
.where(ACCOUNT.ID.between('1', '2', (start, end) -> start < end))
|
||||||
.toSQL();
|
.toSQL();
|
||||||
|
|
||||||
System.out.println(sql);
|
System.out.println(sql);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user