test: 测试 QueryCondition#when 方法。

This commit is contained in:
Suomm 2023-08-11 10:03:16 +08:00
parent bfe552b7db
commit dbc6e79a58

View File

@ -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);
}
}