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



##########
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:
       Yes, I also think so and did it.




-- 
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: notifications-unsubscr...@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to