ソースを参照

修复去除1=1 BUG

Caratacus 6 年 前
コミット
51d85a2d9c

+ 5 - 2
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/AbstractLogicMethod.java

@@ -57,9 +57,12 @@ public abstract class AbstractLogicMethod extends AbstractMethod {
                 true);
             sqlScript += (StringPool.NEWLINE + table.getLogicDeleteSql(true, false) +
                 StringPool.NEWLINE);
+            sqlScript += SqlScriptUtils.convertIf(String.format(" AND ${%s}", Constants.WRAPPER_SQLSEGMENT),
+                String.format("%s != null and %s != '' and ew.notEmptyOfWhere", Constants.WRAPPER_SQLSEGMENT, Constants.WRAPPER_SQLSEGMENT),
+                true);
             sqlScript += SqlScriptUtils.convertIf(String.format(" ${%s}", Constants.WRAPPER_SQLSEGMENT),
-                String.format("%s!=null and %s!=''", Constants.WRAPPER_SQLSEGMENT, Constants.WRAPPER_SQLSEGMENT),
-                false);
+                String.format("%s != null and %s != '' and ew.emptyOfWhere", Constants.WRAPPER_SQLSEGMENT, Constants.WRAPPER_SQLSEGMENT),
+                true);
             sqlScript = SqlScriptUtils.convertChoose("ew!=null", sqlScript,
                 "AND " + table.getLogicDeleteSql(false, false));
             sqlScript = SqlScriptUtils.convertTrim(sqlScript, "WHERE", null, "AND|OR",