CodingBingo commented on a change in pull request #12295:
URL: https://github.com/apache/shardingsphere/pull/12295#discussion_r704934812



##########
File path: 
shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/insert/values/InsertValueContext.java
##########
@@ -102,6 +107,10 @@ private int getParameterIndex(final ExpressionSegment 
valueExpression) {
             }
             if (each instanceof ParameterMarkerExpressionSegment) {
                 result++;
+            } else if (each instanceof BinaryOperationExpression) {

Review comment:
       I have thought about this, and I have extract a new method
   ```
   /**
        * calculate parameter count from collections or return index of 
specific ExpressionSegment.
        *
        * @param assignments expression list
        * @param valueExpression target value expression
        * @return position or index
        */
       public int calculateParameterCountOrIndex(final 
Collection<ExpressionSegment> assignments, final ExpressionSegment 
valueExpression) {
           int result = 0;
           for (ExpressionSegment each : assignments) {
               if (valueExpression != null && valueExpression == each) {
                   return result;
               }
               if (each instanceof ParameterMarkerExpressionSegment) {
                   result++;
               } else if (each instanceof BinaryOperationExpression) {
                   if (((BinaryOperationExpression) each).getRight() instanceof 
ParameterMarkerExpressionSegment) {
                       result++;
                   }
               }
           }
   
           if (valueExpression != null) {
               throw new IllegalArgumentException("Can not get parameter 
index.");
           }
           return result;
       }
   ```
   But in **InsertValueContext** and **OnDuplicateUpdateContext**,  we both 
need this method, I am confused about where should I place this common method.




-- 
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: [email protected]

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


Reply via email to