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

   ## Bug Report
   Mysql 5.7 with shardingsphere 5.1.2
   -- `sharding-demo`.t_user definition
   
   CREATE TABLE `t_user` (
     `user_id` bigint(20) NOT NULL COMMENT '用户唯一ID',
     `fullname` varchar(50) DEFAULT NULL COMMENT '名字',
     `user_type` varchar(255) DEFAULT NULL COMMENT '类型',
     `cipher_pwd` varchar(255) DEFAULT NULL COMMENT '密码',
     `mobile` varchar(100) DEFAULT NULL COMMENT '手机号',
     `mobile_data` varchar(100) DEFAULT NULL COMMENT '手机号',
     `id_card` varchar(60) DEFAULT NULL COMMENT '身份证',
     PRIMARY KEY (`user_id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   
   I want the encryption fullname field,insert is OK, select is OK, bug use 
select distinct fullname will throw exception 
   
   
   Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String 
index out of range: -8
        at java.lang.String.substring(String.java:1967)
        at 
org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.getConjunctionText(AbstractSQLBuilder.java:64)
        at 
org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.toSQL(AbstractSQLBuilder.java:47)
        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:73)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.rewrite(KernelProcessor.java:59)
        at 
org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:47)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createExecutionContext(ShardingSphereStatement.java:474)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.executeQuery(ShardingSphereStatement.java:156)
   
   
   ``` java
       val columnConfigAes =
           new EncryptColumnRuleConfiguration("fullname", "fullname", "", "", 
"name_encryptor", null);
    ....
     val query = connection.createStatement();
       ResultSet rs = query.executeQuery("select distinct t.fullname from 
t_user t ");
   ```
   
   i debug with IDE found `AbstractSQLBuilder` toSQL() method 
getConjunctionText throw exception.
   
![image](https://user-images.githubusercontent.com/3062921/184276353-b40d88fb-5322-45cd-8b00-98ac05a2f9bf.png)
   
   will be create 2 SQLToken with the save start stop index .
   
   
   


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