You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "GaoEinstein (via GitHub)" <gi...@apache.org> on 2023/07/14 03:37:15 UTC
[GitHub] [shardingsphere] GaoEinstein commented on issue #25690: The problem of using "join query" during update sql using the sharding-encrypt module
GaoEinstein commented on issue #25690:
URL: https://github.com/apache/shardingsphere/issues/25690#issuecomment-1635219871
I have solved this problem, and it was relatively simple.
code position:com.xsyx.storage.encrypt.core.rewrite.JoinUpdateFixEnhancedEncryptAssignmentSQLTokenGenerator#generateParameterSQLToken
`private EncryptAssignmentToken generateParameterSQLToken(final String tableName, final AssignmentSegment assignmentSegment) {
ColumnSegment columnSegment = assignmentSegment.getColumns().get(0);
EncryptParameterAssignmentToken result = new EncryptParameterAssignmentToken(columnSegment.getStartIndex(), assignmentSegment.getStopIndex());
String columnName = columnSegment.getIdentifier().getValue();
addCipherColumn(tableName, columnName, result, columnSegment);
addAssistedQueryColumn(tableName, columnName, result, columnSegment);
addPlainColumn(tableName, columnName, result, columnSegment);
return result;
}
private void addCipherColumn(final String tableName, final String columnName, final EncryptParameterAssignmentToken token,
ColumnSegment columnSegment) {
String cipherColumn = encryptRule.getCipherColumn(tableName, columnName);
token.addColumnName(this.splicingPrefixOfTableAlias(cipherColumn, columnSegment));
}
private String splicingPrefixOfTableAlias(String tokenStr, ColumnSegment columnSegment) {
String tableAlias = this.getTableAlias(columnSegment);
if (StringUtils.isNotEmpty(tableAlias)) {
return String.format("%s.%s", tableAlias, tokenStr);
}
return tokenStr;
}
private String getTableAlias(ColumnSegment columnSegment) {
Optional<OwnerSegment> owner = columnSegment.getOwner();
if (owner.isPresent()) {
OwnerSegment ownerSegment = owner.get();
return ownerSegment.getIdentifier().getValue();
} else {
return null;
}
}`
--
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-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org