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



##########
File path: 
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/impl/EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.java
##########
@@ -59,6 +59,9 @@ public void rewrite(final ParameterBuilder parameterBuilder, 
final InsertStateme
             Optional<EncryptAlgorithm> encryptor = 
getEncryptRule().findEncryptor(schemaName, tableName, encryptLogicColumnName);
             encryptor.ifPresent(optional -> {
                 Object plainColumnValue = 
onDuplicateKeyUpdateValueContext.getValue(columnIndex);
+                if (plainColumnValue == null) {

Review comment:
       Hi @cheese8, please put `null` on the left.

##########
File path: 
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/pojo/EncryptLiteralAssignmentToken.java
##########
@@ -56,8 +57,13 @@ public String toString() {
         
         private final Object value;
         
+        private final boolean exceptional;
+        
         @Override
         public String toString() {
+            if (exceptional) {
+                return String.format("%s = VALUES(%s)", columnName, value);

Review comment:
       It seems that hard-writing like this can't solve the internal rewriting 
problem of other functions.

##########
File path: 
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertOnUpdateTokenGenerator.java
##########
@@ -72,6 +74,12 @@ protected boolean isGenerateSQLTokenForEncrypt(final 
SQLStatementContext sqlStat
         if (assignmentSegment.getValue() instanceof 
ParameterMarkerExpressionSegment) {
             return Optional.of(generateParameterSQLToken(tableName, 
assignmentSegment));
         }
+        if (assignmentSegment.getValue() instanceof FunctionSegment) {
+            FunctionSegment functionSegment = (FunctionSegment) 
assignmentSegment.getValue();
+            if ("VALUES".equals(functionSegment.getFunctionName()) && 
functionSegment.getParameters().size() == 0) {

Review comment:
       @cheese8 `0 == functionSegment.getParameters().size()` may be better.

##########
File path: 
shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/insert/values/OnDuplicateUpdateContext.java
##########
@@ -79,8 +80,16 @@ public OnDuplicateUpdateContext(final 
Collection<AssignmentSegment> assignments,
      */
     public Object getValue(final int index) {
         ExpressionSegment valueExpression = valueExpressions.get(index);
-        return valueExpression instanceof ParameterMarkerExpressionSegment 
-                ? 
parameters.get(getParameterIndex((ParameterMarkerExpressionSegment) 
valueExpression)) : ((LiteralExpressionSegment) valueExpression).getLiterals();
+        if (valueExpression instanceof ParameterMarkerExpressionSegment) {
+            return 
parameters.get(getParameterIndex((ParameterMarkerExpressionSegment) 
valueExpression));
+        }
+        if (valueExpression instanceof FunctionSegment && ((FunctionSegment) 
valueExpression).getParameters().size() == 0) {

Review comment:
       Same problem.




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