yanyzy commented on a change in pull request #3246: fix data mask for oracle
URL: 
https://github.com/apache/incubator-shardingsphere/pull/3246#discussion_r334767697
 
 

 ##########
 File path: 
sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultMetaData.java
 ##########
 @@ -143,21 +149,35 @@ public boolean isCaseSensitive(final int columnIndex) 
throws SQLException {
      * @throws SQLException SQL exception
      */
     public Optional<ShardingEncryptor> getShardingEncryptor(final int 
columnIndex) throws SQLException {
-        String logicTable = getTableName(columnIndex);
-        return encryptRule.findShardingEncryptor(logicTable, 
getLogicColumn(logicTable, columnIndex));
-    }
-    
-    private String getTableName(final int columnIndex) throws SQLException {
-        String actualTableName = resultSetMetaData.getTableName(columnIndex);
-        if (null == shardingRule) {
-            return actualTableName;
+        final String actualColumn = 
resultSetMetaData.getColumnName(columnIndex);
+        if (null == sqlStatementContext) {
+            return Optional.absent();
+        }
+        final Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
+        for (String each : tableNames) {
+            Optional<ShardingEncryptor> result = 
findShardingEncryptorWithTable(actualColumn, each);
+            if (result.isPresent()) {
+                return result;
+            }
         }
-        Optional<TableRule> tableRule = 
shardingRule.findTableRuleByActualTable(actualTableName);
-        return tableRule.isPresent() ? tableRule.get().getLogicTable() : 
actualTableName;
+        return Optional.absent();
     }
-    
-    private String getLogicColumn(final String tableName, final int 
columnIndex) throws SQLException {
-        String columnLabel = resultSetMetaData.getColumnName(columnIndex);
-        return encryptRule.isCipherColumn(tableName, columnLabel) ? 
encryptRule.getLogicColumn(tableName, columnLabel) : columnLabel;
+
+    private Optional<ShardingEncryptor> findShardingEncryptorWithTable(final 
String actualColumn, final String logicTableName) {
+        if (null == encryptRule) {
+            return Optional.absent();
+        }
+        final Collection<String> actualColumns = 
encryptRule.findEncryptTable(logicTableName)
+                .transform(new Function<EncryptTable, Collection<String>>() {
+                    @Override
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to