Skip to content

Commit

Permalink
Fix merge exception without encrypt rule in database (#33708)
Browse files Browse the repository at this point in the history
* Fix merge exception without encrypt rule in database

* Fix merge exception without encrypt rule in database
  • Loading branch information
FlyingZC authored Nov 18, 2024
1 parent 5a2e879 commit 684605b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
1. Sharding: Remove ShardingRouteAlgorithmException check logic temporarily to support different actual table name config - [#33367](https://github.com/apache/shardingsphere/pull/33367)
1. Sharding: Fix SQL COUNT with GROUP BY to prevent incorrect row returns - [#33380](https://github.com/apache/shardingsphere/pull/33380)
1. Sharding: Fix avg, sum, min, max function return empty data when no query result return - [#33449](https://github.com/apache/shardingsphere/pull/33449)
1. Encrypt: Fix merge exception without encrypt rule in database - [#33708](https://github.com/apache/shardingsphere/pull/33708)

### Change Logs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public Object getValue(final int columnIndex, final Class<?> type) throws SQLExc
ShardingSphereDatabase database = metaData.containsDatabase(columnProjection.get().getColumnBoundInfo().getOriginalDatabase().getValue())
? metaData.getDatabase(columnProjection.get().getColumnBoundInfo().getOriginalDatabase().getValue())
: this.database;
EncryptRule rule = database.getRuleMetaData().getSingleRule(EncryptRule.class);
if (!rule.findEncryptTable(originalTableName).map(optional -> optional.isEncryptColumn(originalColumnName)).orElse(false)) {
Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
if (!rule.isPresent() || !rule.get().findEncryptTable(originalTableName).map(optional -> optional.isEncryptColumn(originalColumnName)).orElse(false)) {
return mergedResult.getValue(columnIndex, type);
}
Object cipherValue = mergedResult.getValue(columnIndex, Object.class);
EncryptColumn encryptColumn = rule.getEncryptTable(originalTableName).getEncryptColumn(originalColumnName);
EncryptColumn encryptColumn = rule.get().getEncryptTable(originalTableName).getEncryptColumn(originalColumnName);
String schemaName = selectStatementContext.getTablesContext().getSchemaName()
.orElseGet(() -> new DatabaseTypeRegistry(selectStatementContext.getDatabaseType()).getDefaultSchemaName(database.getName()));
try {
Expand Down

0 comments on commit 684605b

Please sign in to comment.