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

 ##########
 File path: 
sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultMetaData.java
 ##########
 @@ -155,6 +171,29 @@ private String getTableName(final int columnIndex) throws 
SQLException {
         Optional<TableRule> tableRule = 
shardingRule.findTableRuleByActualTable(actualTableName);
         return tableRule.isPresent() ? tableRule.get().getLogicTable() : 
actualTableName;
     }
+
+    private String getTableName(final int columnIndex, final 
SQLStatementContext sqlStatementContext) throws SQLException {
+        final Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
+        for (String each : tableNames) {
+            if (isCurrentTable(columnIndex, each)) {
+                return each;
+            }
+        }
+        return "";
+    }
+
+    private boolean isCurrentTable(final int columnIndex, final String 
logicTableName) throws SQLException {
+        Collection<String> actualColumns = 
encryptRule.findEncryptTable(logicTableName)
+                .transform(new Function<EncryptTable, Collection<String>>() {
+                    @Override
+                    public Collection<String> apply(final EncryptTable 
encryptTable) {
+                        return encryptTable.getCipherColumns();
+                    }
+                })
+                .or(Collections.<String>emptyList());
+        String actualColumn = resultSetMetaData.getColumnName(columnIndex);
 
 Review comment:
   Good idea, i will modify it like this!

----------------------------------------------------------------
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