From 0e3898784d174e80dcd97012d4d65246c3ea1985 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 11 Aug 2023 16:12:07 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=8A=A8=E6=80=81=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=B5=8B=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coretest/DynamicConditionTest.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java index 613f8a57..ce020d6d 100644 --- a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java +++ b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java @@ -17,6 +17,8 @@ package com.mybatisflex.coretest; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.util.CollectionUtil; +import com.mybatisflex.core.util.StringUtil; import org.junit.Test; import java.util.Arrays; @@ -50,7 +52,28 @@ public class DynamicConditionTest { String sql = QueryWrapper.create() .from(ACCOUNT) .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(); System.out.println(sql);