mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
fix: applyFunc 子查询异常
This commit is contained in:
parent
8ecc698723
commit
d7f7f19fac
@ -414,6 +414,12 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
|||||||
Arrays.stream(funcConsumer.getArgs()).map(func -> {
|
Arrays.stream(funcConsumer.getArgs()).map(func -> {
|
||||||
if (func instanceof Fun) {
|
if (func instanceof Fun) {
|
||||||
Fun<?, ?> fun = (Fun<?, ?>) func;
|
Fun<?, ?> fun = (Fun<?, ?>) func;
|
||||||
|
if (fun.isSub()) {
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
MPJLambdaWrapper wrapper = fun.getSub().apply((MPJLambdaWrapper) subInstance(fun.getClazz()));
|
||||||
|
return WrapperUtils.buildUnionSqlByWrapper(fun.getClazz(),
|
||||||
|
fun.getSub().apply(wrapper));
|
||||||
|
}
|
||||||
return columnToString(index, fun.getAlias(), fun.getFunc(), false, PrefixEnum.CD_FIRST, false);
|
return columnToString(index, fun.getAlias(), fun.getFunc(), false, PrefixEnum.CD_FIRST, false);
|
||||||
}
|
}
|
||||||
return columnToString(index, null, func, false, PrefixEnum.CD_FIRST, false);
|
return columnToString(index, null, func, false, PrefixEnum.CD_FIRST, false);
|
||||||
|
@ -57,4 +57,26 @@ public class ApplyFuncTest {
|
|||||||
list1.forEach(System.out::println);
|
list1.forEach(System.out::println);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void applyFunc1() {
|
||||||
|
ThreadLocalUtils.set("""
|
||||||
|
SELECT
|
||||||
|
t.pid, t.`name`, t.`json`, t.sex, t.head_img, t.create_time, t.address_id,
|
||||||
|
t.address_id2, t.del, t.create_by, t.update_by
|
||||||
|
FROM `user` t
|
||||||
|
LEFT JOIN address t1 ON (t1.user_id = t.id)
|
||||||
|
WHERE t.del = false
|
||||||
|
AND t1.del = false
|
||||||
|
AND (concat(t.id, t.id, (SELECT st.id, st.id FROM `user` st WHERE st.del = false AND (st.id = ? AND st.id = ?)), ?) IS NOT NULL)
|
||||||
|
""");
|
||||||
|
JoinWrappers.lambda(UserDO.class)
|
||||||
|
.selectAll(UserDO.class, UserDO::getId)
|
||||||
|
.leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
|
||||||
|
.applyFunc("concat(%s, %s, %s, {0}) is not null", arg -> arg.accept(
|
||||||
|
UserDO::getId,
|
||||||
|
Fun.f("t", UserDO::getId),
|
||||||
|
Fun.f(UserDO.class, user -> user.select(UserDO::getId).eq(UserDO::getId, 1))
|
||||||
|
), "12")
|
||||||
|
.list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user