strongduanmu commented on a change in pull request #10816:
URL: https://github.com/apache/shardingsphere/pull/10816#discussion_r652272358



##########
File path: 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/IndexToken.java
##########
@@ -62,7 +63,12 @@ public IndexToken(final int startIndex, final int stopIndex, 
final IdentifierVal
     
     @Override
     public String toString(final RouteUnit routeUnit) {
-        return identifier.getQuoteCharacter().wrap(getIndexValue(routeUnit));
+        String quotedIndexName = 
identifier.getQuoteCharacter().wrap(getIndexValue(routeUnit));
+        return isGeneratedIndex() ? " " + quotedIndexName + " " : 
quotedIndexName;

Review comment:
       > Will it be better to move blank space to the outer?
   
   @tristaZero Extracting to the outside means that we need to pass more 
parameters in RouteSQLBuilder. In addition, I refer to other tokens, and 
similar string splicing also exists.
   
   ```java
   // ShardingInsertValuesToken
   @Override
   public String toString(final RouteUnit routeUnit) {
       StringBuilder result = new StringBuilder();
       appendInsertValue(routeUnit, result);
       result.delete(result.length() - 2, result.length());
       return result.toString();
   }
   
   private void appendInsertValue(final RouteUnit routeUnit, final 
StringBuilder stringBuilder) {
       for (InsertValue each : getInsertValues()) {
           if (isAppend(routeUnit, (ShardingInsertValue) each)) {
               stringBuilder.append(each).append(", ");
           }
       }
   }
   
   // OrderByToken
   @Override
   public String toString() {
       StringBuilder result = new StringBuilder();
       result.append(" ORDER BY ");
       for (int i = 0; i < columnLabels.size(); i++) {
           if (0 == i) {
               result.append(columnLabels.get(0)).append(" 
").append(orderDirections.get(i).name());
           } else {
               result.append(",").append(columnLabels.get(i)).append(" 
").append(orderDirections.get(i).name());
           }
       }
       result.append(" ");
       return result.toString();
   }
   ```




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