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



##########
File path: 
shardingsphere-infra/shardingsphere-infra-rewrite/shardingsphere-infra-rewrite-engine/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/impl/AbstractSQLBuilder.java
##########
@@ -41,15 +43,30 @@ public final String toSQL() {
         Collections.sort(context.getSqlTokens());
         StringBuilder result = new StringBuilder();
         result.append(context.getSql(), 0, 
context.getSqlTokens().get(0).getStartIndex());
-        for (SQLToken each : context.getSqlTokens()) {
-            result.append(getSQLTokenText(each));
+        int size = context.getSqlTokens().size();
+        for (int index = 0; index < size; index++) {
+            if (index < size - 1 && 
isSubstitutableNeedIgnore(context.getSqlTokens().get(index), 
context.getSqlTokens().get(index + 1))) {
+                continue;
+            }
+            SQLToken each = context.getSqlTokens().get(index);
+            result.append(each instanceof Combinational ? 
getCombinationalText((Combinational) each) : getSQLTokenText(each));
             result.append(getConjunctionText(each));
         }
         return result.toString();
     }
-    
+
     protected abstract String getSQLTokenText(SQLToken sqlToken);
-    
+
+    private String getCombinationalText(final Combinational 
combinationalSQLToken) {
+        StringBuilder result = new StringBuilder();
+        Collection<SQLToken> subSQLTokens = 
combinationalSQLToken.getMaterials();
+        for (SQLToken subSQLToken : subSQLTokens) {
+            result.append(getSQLTokenText(subSQLToken));
+            result.append(getConjunctionText(subSQLToken));
+        }
+        return result.toString();

Review comment:
       Thank you for the excellent design. I just reply the issue and give some 
advices for me. 




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to