cheese8 commented on a change in pull request #14309:
URL: https://github.com/apache/shardingsphere/pull/14309#discussion_r777873736
##########
File path:
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/impl/EncryptInsertOnUpdateTokenGenerator.java
##########
@@ -61,9 +65,15 @@ protected boolean isGenerateSQLTokenForEncrypt(final
SQLStatementContext sqlStat
}
String schemaName = insertStatementContext.getSchemaName();
for (AssignmentSegment each : onDuplicateKeyColumnsSegments) {
- if (getEncryptRule().findEncryptor(schemaName, tableName,
each.getColumns().get(0).getIdentifier().getValue()).isPresent()) {
- generateSQLToken(schemaName, tableName,
each).ifPresent(result::add);
- }
+ if (each.getValue() instanceof FunctionSegment &&
"VALUES".equalsIgnoreCase(((FunctionSegment)
each.getValue()).getFunctionName())) {
+ boolean leftEncryptorPresent =
getEncryptRule().findEncryptor(schemaName, tableName,
each.getColumns().get(0).getIdentifier().getValue()).isPresent();
+ ColumnSegment rightColumn = (ColumnSegment) ((FunctionSegment)
each.getValue()).getParameters().stream().findFirst().get();
+ boolean rightEncryptorPresent =
getEncryptRule().findEncryptor(schemaName, tableName,
rightColumn.getIdentifier().getValue()).isPresent();
+ if (!leftEncryptorPresent && !rightEncryptorPresent) {
+ continue;
+ }
+ }
+ generateSQLToken(schemaName, tableName,
each).ifPresent(result::add);
Review comment:
The guard clause check is above. `continue` block processed.
--
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]