diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryOrderBy.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryOrderBy.java index e033ed4a..5110679b 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryOrderBy.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryOrderBy.java @@ -29,7 +29,7 @@ import java.util.List; */ public class QueryOrderBy implements CloneSupport { - private QueryColumn queryColumn; + QueryColumn queryColumn; /** * asc, desc diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java index 2186f12d..2d5ca073 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryWrapper.java @@ -2351,6 +2351,14 @@ public class QueryWrapper extends BaseQueryWrapper { Object[] paramValues = ArrayUtil.concat(whereValues, havingValues); + // orderBy 参数 + for (QueryOrderBy orderBy : orderBys) { + QueryColumn orderByColumn = orderBy.queryColumn; + if (orderByColumn != null && orderByColumn instanceof HasParamsColumn) { + paramValues = ArrayUtil.concat(paramValues, ((HasParamsColumn) orderByColumn).getParamValues()); + } + } + // unions 参数 if (CollectionUtil.isNotEmpty(unions)) { for (UnionWrapper union : unions) { diff --git a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/QueryWrapperTest.java b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/QueryWrapperTest.java index 8fe1cff7..658457fb 100644 --- a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/QueryWrapperTest.java +++ b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/QueryWrapperTest.java @@ -23,6 +23,8 @@ import com.mybatisflex.core.query.QueryWrapper; import org.junit.Assert; import org.junit.Test; +import java.util.Arrays; + import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT; import static com.mybatisflex.core.query.QueryMethods.*; @@ -66,4 +68,16 @@ public class QueryWrapperTest { } + @Test + public void testOrderByValue(){ + QueryWrapper wrapper = QueryWrapper.create() + .select("*") + .from(Account.class) + .orderBy(case_() + .when(new QueryColumn("id").in(1, 2, 3)) + .then(1).end().asc() + ); + Assert.assertEquals(CPI.getValueArray(wrapper).length, 3); + } + }