diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/MPJBaseMethod.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/MPJBaseMethod.java index 3ac093c..e99d4f8 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/MPJBaseMethod.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/MPJBaseMethod.java @@ -42,7 +42,8 @@ public interface MPJBaseMethod extends Constants { if (ConfigProperties.subTableLogic) { sqlScript += (String.format("${%s.subLogicSql}", WRAPPER) + NEWLINE); } - sqlScript += SqlScriptUtils.convertIf(String.format("AND ${%s}", WRAPPER_SQLSEGMENT), String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT, WRAPPER_NONEMPTYOFWHERE), true); + String s = SqlScriptUtils.convertIf("AND", WRAPPER_NONEMPTYOFNORMAL, true); + sqlScript += SqlScriptUtils.convertIf(s+String.format(" ${%s}", WRAPPER_SQLSEGMENT), String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT, WRAPPER_NONEMPTYOFWHERE), true); sqlScript = SqlScriptUtils.convertWhere(sqlScript) + NEWLINE; sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", WRAPPER_SQLSEGMENT), String.format("%s != null and %s != '' and %s", WRAPPER_SQLSEGMENT, WRAPPER_SQLSEGMENT, WRAPPER_EMPTYOFWHERE), true); sqlScript = SqlScriptUtils.convertIf(sqlScript, String.format("%s != null", WRAPPER), true);