FakeKotaro opened a new issue, #25005:
URL: https://github.com/apache/shardingsphere/issues/25005

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   5.3.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   My SQL:
   ```sql
   SELECT DISTINCT name FROM user
   ```
   
   My Encryption Config:
   ```yaml
   rules:
   - !ENCRYPT
       encryptors:
         encryptor-aes:
           props:
             aes-key-value: 123456a
           type: AES
       tables:
         user:
           columns:
             name:
               plainColumn: name
               cipherColumn: name_encode
               encryptorName: encryptor-aes
   
   ```
   
   Then it throws an exception:
   ```
   Caused by: java.lang.StringIndexOutOfBoundsException: String index out of 
range: -4
        at java.lang.String.substring(String.java:1967)
        at 
org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.getConjunctionText(AbstractSQLBuilder.java:74)
        at 
org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.toSQL(AbstractSQLBuilder.java:57)
        at 
org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.addSQLRewriteUnits(RouteSQLRewriteEngine.java:96)
        at 
org.apache.shardingsphere.infra.rewrite.engine.RouteSQLRewriteEngine.rewrite(RouteSQLRewriteEngine.java:72)
        at 
org.apache.shardingsphere.infra.rewrite.SQLRewriteEntry.rewrite(SQLRewriteEntry.java:79)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:65)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:52)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionContext(ShardingSpherePreparedStatement.java:551)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:407)
        ... 94 more
   ```
   
   The expected actual SQL show be:
   ```sql
   SELECT DISTINCT name_encode AS name FROM user 
   ```
   
   It's worth noting that this issue has been mentioned before  in version 
5.1.2, but it has never been fixed #20096 
   
   
   
   
   
   
   
   
   


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

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to