mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 09:08:24 +08:00
fix: 解决orderBy时传入的变量失效问题
This commit is contained in:
parent
4e4556e776
commit
0edf12b05d
@ -29,7 +29,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class QueryOrderBy implements CloneSupport<QueryOrderBy> {
|
public class QueryOrderBy implements CloneSupport<QueryOrderBy> {
|
||||||
|
|
||||||
private QueryColumn queryColumn;
|
QueryColumn queryColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* asc, desc
|
* asc, desc
|
||||||
|
|||||||
@ -2351,6 +2351,14 @@ public class QueryWrapper extends BaseQueryWrapper<QueryWrapper> {
|
|||||||
|
|
||||||
Object[] paramValues = ArrayUtil.concat(whereValues, havingValues);
|
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 参数
|
// unions 参数
|
||||||
if (CollectionUtil.isNotEmpty(unions)) {
|
if (CollectionUtil.isNotEmpty(unions)) {
|
||||||
for (UnionWrapper union : unions) {
|
for (UnionWrapper union : unions) {
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
|
||||||
import static com.mybatisflex.core.query.QueryMethods.*;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user