diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/Brackets.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/Brackets.java index e4220922..1d37f44b 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/Brackets.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/Brackets.java @@ -83,15 +83,15 @@ public class Brackets extends QueryCondition { if (checkEffective()) { String childSql = childCondition.toSql(queryTables, dialect); if (StringUtil.isNotBlank(childSql)) { - QueryCondition prevCondition = getPrevEffectiveCondition(); - if (prevCondition != null) { - childSql = prevCondition.connector + "(" + childSql + ")"; + QueryCondition prevEffectiveCondition = getPrevEffectiveCondition(); + if (prevEffectiveCondition != null) { + childSql = prevEffectiveCondition.connector + "(" + childSql + ")"; } else if (StringUtil.isNotBlank(sqlNext)) { childSql = "(" + childSql + ")"; } sql.append(childSql); } else { - //all child conditions is not effective + //all child conditions are not effective //fixed gitee #I6W89G this.effective = false; } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java index d71bd807..98f10a09 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java @@ -217,13 +217,10 @@ public class QueryCondition implements CloneSupport { protected QueryCondition getPrevEffectiveCondition() { - if (prev != null && prev.checkEffective()) { - return prev; - } else if (prev != null) { - return prev.getPrevEffectiveCondition(); - } else { + if (prev == null) { return null; } + return prev.checkEffective() ? prev : prev.getPrevEffectiveCondition(); }