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



##########
File path: 
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertOnUpdateTokenGenerator.java
##########
@@ -95,6 +108,46 @@ private EncryptAssignmentToken 
generateLiteralSQLToken(final String schemaName,
         return result;
     }
     
+    private EncryptAssignmentToken generateValuesSQLToken(final String 
schemaName, final String tableName, final AssignmentSegment assignmentSegment, 
final FunctionSegment functionSegment) {
+        ColumnSegment columnSegment = assignmentSegment.getColumns().get(0);
+        String column = columnSegment.getIdentifier().getValue();
+        ColumnSegment valueColumnSegment = (ColumnSegment) 
functionSegment.getParameters().stream().findFirst().get();
+        String valueColumn = valueColumnSegment.getIdentifier().getValue();
+        
+        EncryptLiteralAssignmentToken result = new 
EncryptLiteralAssignmentToken(columnSegment.getStartIndex(), 
assignmentSegment.getStopIndex());
+        
+        boolean cipherColumnPresent = 
getEncryptRule().findEncryptor(schemaName, tableName, column).isPresent();
+        boolean cipherValueColumnPresent = 
getEncryptRule().findEncryptor(schemaName, tableName, valueColumn).isPresent();
+        if (cipherColumnPresent && cipherValueColumnPresent) {
+            String cipherColumn = getEncryptRule().getCipherColumn(tableName, 
column);
+            String cipherValueColumn = 
getEncryptRule().getCipherColumn(tableName, valueColumn);
+            result.addAssignment(cipherColumn, String.format("VALUES(%s)", 
cipherValueColumn), false);
+        } else if (cipherColumnPresent != cipherValueColumnPresent) {
+            throw new ShardingSphereException("The SQL clause `%s` is 
unsupported in encrypt rule.", String.format("%s=VALUES(%s)", column, 
valueColumn));

Review comment:
       I think it is possible if column and value is different column




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