You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/10/26 12:56:11 UTC

[GitHub] [incubator-shardingsphere] sunbufu commented on issue #3352: Encrypt error when associated query with same column name.

sunbufu commented on issue #3352: Encrypt error when associated query with same column name.
URL: https://github.com/apache/incubator-shardingsphere/issues/3352#issuecomment-546600331
 
 
   Hi @KomachiSion , I think this issue is same like https://github.com/apache/incubator-shardingsphere/issues/3194. The root cause of this issue is that we can't get tableName by columnIndex correctly.
   ```java
       /**
        * Get sharding encryptor.
        * 
        * @param columnIndex column index
        * @return sharding encryptor
        * @throws SQLException SQL exception
        */
       public Optional<ShardingEncryptor> getShardingEncryptor(final int columnIndex) throws SQLException {
           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;
               }
           }
           return Optional.absent();
       }
   ```
   The complete code is [here](https://github.com/apache/incubator-shardingsphere/blob/dev/sharding-core/sharding-core-execute/src/main/java/org/apache/shardingsphere/core/execute/sql/execute/result/QueryResultMetaData.java#L151). You can see SS try to get encryptor with all tableNames in sqlStatementContext, so we can't get encryptor correctly by same column name. 
   I think maybe **we should discuss the issue until get a perfect solution.**

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services