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 2020/01/20 11:10:46 UTC

[GitHub] [incubator-shardingsphere] longjy commented on a change in pull request #3959: Get ciphertext column as a string

longjy commented on a change in pull request #3959: Get ciphertext column as a string
URL: https://github.com/apache/incubator-shardingsphere/pull/3959#discussion_r368492269
 
 

 ##########
 File path: encrypt-core/encrypt-core-merge/src/main/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResult.java
 ##########
 @@ -44,15 +44,15 @@
     public boolean next() throws SQLException {
         return mergedResult.next();
     }
-    
+
     @Override
     public Object getValue(final int columnIndex, final Class<?> type) throws SQLException {
-        Object value = mergedResult.getValue(columnIndex, type);
-        if (null == value || !queryWithCipherColumn) {
-            return value;
+        Optional<Encryptor> encryptor;
+        if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent()) {
+            return mergedResult.getValue(columnIndex, type);
         }
-        Optional<Encryptor> encryptor = metaData.findEncryptor(columnIndex);
-        return encryptor.isPresent() ? encryptor.get().decrypt(value.toString()) : value;
+        String ciphertext = (String) mergedResult.getValue(columnIndex, String.class);
+        return null == ciphertext ? null : encryptor.get().decrypt(ciphertext);
 
 Review comment:
   The encryptor should also judge whether it is null. For example, the id(bigint) is unencrypted and should be executed
   `mergedResult.getValue(columnIndex, type)`
   
   Or you mean it's too complicated:
   `if (!queryWithCipherColumn || !(encryptor = metaData.findEncryptor(columnIndex)).isPresent())`
   
   

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