You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/01 03:52:24 UTC

[GitHub] [shardingsphere] terrymanu commented on a change in pull request #12140: Refactor getShowLikePattern

terrymanu commented on a change in pull request #12140:
URL: https://github.com/apache/shardingsphere/pull/12140#discussion_r699823558



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SQLUtil.java
##########
@@ -280,12 +279,12 @@ public static String trimComment(final String sql) {
     }
     
     /**
-     * Get show like pattern.
+     * Replace all SQL pattern to java regex.
      * 
-     * @param showLike show like segment
-     * @return pattern
+     * @param pattern SQL pattern
+     * @return java regex
      */
-    public static String getShowLikePattern(final ShowLikeSegment showLike) {
-        return showLike.getPattern().replaceAll("_", ".{1}").replaceAll("%", ".*");
+    public static String handleSQLPattern(final String pattern) {
+        return pattern.contains("_") || pattern.contains("%") ? pattern.replaceAll("_", ".").replaceAll("%", ".*") : pattern;

Review comment:
       Please consider if the original varchar contains `%` or `_`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org