ballcat-projects/ballcat

LambdaAliasQueryWrapperX 别名在 and 条件下失效

jiuyouma opened this issue · 0 comments

实体定义:@TableAlias("si")
代码片段

LambdaAliasQueryWrapperX wrapper = WrappersX.lambdaAliasQueryX(SheetInfo.class);
wrapper.eqIfPresent(SheetInfo::getEditorBy, dto.getSysEditId()).eqIfPresent(SheetInfo::getState, dto.getState())
.and(StrUtil.isNotBlank(dto.getSearch()), w -> {
w.like(SheetInfo::getNo, dto.getSearch()).or().inSql(SheetInfo::getContractId,
String.format(
"select id from contract_info where deleted=0 and company_name regexp '%s'",
dto.getSearch()));
}).orderByDesc(SheetInfo::getMainId);

输出sql

select si.*,t1.name from sheet_info si
join ky_app.contract_info t1 on t1.deleted = 0 and t1.id = si.contract_id and si.deleted=0
where ((no like 'key') or contract_id in (select id from contract_info where deleted=0 and company_name regexp 'key'))
order by si.main_id desc