miemie 7 years ago
parent
commit
fbeaa0254b

+ 3 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/AbstractMethod.java

@@ -125,7 +125,7 @@ public abstract class AbstractMethod {
         String sqlScript = table.getAllSqlSet(logic, prefix);
         if (ew) {
             sqlScript += StringPool.NEWLINE;
-            sqlScript += SqlScriptUtils.convertIf(String.format("${%s}", Constants.U_WRAPPER_SQL_SET),
+            sqlScript += SqlScriptUtils.convertIf(SqlScriptUtils.unSafeParam(Constants.U_WRAPPER_SQL_SET),
                 String.format("%s != null and %s != null", Constants.WRAPPER, Constants.U_WRAPPER_SQL_SET), false);
         }
         sqlScript = SqlScriptUtils.convertTrim(sqlScript, "SET", null, null, ",");
@@ -153,7 +153,7 @@ public abstract class AbstractMethod {
         }
         return SqlScriptUtils.convertChoose(String.format("%s != null and %s != null",
             Constants.WRAPPER, Constants.Q_WRAPPER_SQL_SELECT),
-            String.format("${%s}", Constants.Q_WRAPPER_SQL_SELECT), selectColumns);
+            SqlScriptUtils.unSafeParam(Constants.Q_WRAPPER_SQL_SELECT), selectColumns);
     }
 
     /**
@@ -166,7 +166,7 @@ public abstract class AbstractMethod {
     protected String sqlSelectObjsColumns(TableInfo table) {
         return SqlScriptUtils.convertChoose(String.format("%s != null and %s != null",
             Constants.WRAPPER, Constants.Q_WRAPPER_SQL_SELECT),
-            String.format("${%s}", Constants.Q_WRAPPER_SQL_SELECT), table.getAllSqlSelect());
+            SqlScriptUtils.unSafeParam(Constants.Q_WRAPPER_SQL_SELECT), table.getAllSqlSelect());
     }
 
     /**

+ 1 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/StringPool.java

@@ -77,6 +77,7 @@ public interface StringPool {
     String ONE 				= "1";
     String ZERO				= "0";
     String DOLLAR_LEFT_BRACE= "${";
+    String HASH_LEFT_BRACE  = "#{";
     String CRLF				= "\r\n";
 
     String HTML_NBSP		= " ";

+ 1 - 6
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/SqlScriptUtils.java

@@ -28,11 +28,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
  */
 public final class SqlScriptUtils {
 
-    /**
-     * 脚本符号: #{
-     */
-    private static final String HASH_LEFT_BRACE = StringPool.HASH + StringPool.LEFT_BRACE;
-
     private SqlScriptUtils() {
         // ignore
     }
@@ -145,7 +140,7 @@ public final class SqlScriptUtils {
      * @return 脚本
      */
     public static String safeParam(final String param) {
-        return HASH_LEFT_BRACE + param + StringPool.RIGHT_BRACE;
+        return StringPool.HASH_LEFT_BRACE + param + StringPool.RIGHT_BRACE;
     }
 
     /**