mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
!98 fix: 修复 Brackets#containsTable 不向下继续判断错误
Merge pull request !98 from 王帅/main
This commit is contained in:
commit
ae0a3a95ed
@ -103,7 +103,10 @@ public class Brackets extends QueryCondition {
|
||||
|
||||
@Override
|
||||
boolean containsTable(String... tables) {
|
||||
return childCondition != null && childCondition.containsTable(tables);
|
||||
if (childCondition != null && childCondition.containsTable(tables)) {
|
||||
return true;
|
||||
}
|
||||
return nextContainsTable(tables);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -268,7 +268,7 @@ public class QueryCondition implements CloneSupport<QueryCondition> {
|
||||
return nextContainsTable(tables);
|
||||
}
|
||||
|
||||
private boolean nextContainsTable(String... tables) {
|
||||
boolean nextContainsTable(String... tables) {
|
||||
if (next == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -16,7 +16,10 @@
|
||||
|
||||
package com.mybatisflex.test.common;
|
||||
|
||||
import com.mybatisflex.core.query.CPI;
|
||||
import com.mybatisflex.core.query.QueryCondition;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -71,4 +74,21 @@ class QueryWrapperTest {
|
||||
System.out.println(queryWrapper.toSQL());
|
||||
}
|
||||
|
||||
@Test
|
||||
void test03() {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select()
|
||||
.from(USER.as("u"))
|
||||
.leftJoin(USER_ROLE).as("ur").on(USER.USER_ID.eq(USER_ROLE.USER_ID))
|
||||
.where(QueryCondition.createEmpty())
|
||||
.and(USER.USER_ID.eq(1).or(USER.USER_ID.in(
|
||||
QueryWrapper.create().select(USER_ROLE.USER_ID).from(USER_ROLE)))
|
||||
)
|
||||
.and(USER_ROLE.USER_ID.eq(1));
|
||||
System.out.println(queryWrapper.toSQL());
|
||||
QueryCondition whereQueryCondition = CPI.getWhereQueryCondition(queryWrapper);
|
||||
boolean contained = CPI.containsTable(whereQueryCondition, "tb_user_role");
|
||||
Assertions.assertTrue(contained);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user