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

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   sharding jdbc 5.4.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   sharding jdbc
   
   ### Expected behavior
   I want to my insert sql execute like this:
   insert into t_user_info (p_id, user_name) values(1,1)
   
   
   ### Actual behavior
   sharding jdbc try to rewrite my sql like this:
   insert into t_user_info (p_id, user_name) values(1,1)(1,1)
   
   
   ### Reason analyze (If you can)
   I config sharding jdbc to manage 2 tables:t_user_info,t_user_bill。
   when executing t_user_info's insert sql :insert into t_user_info (p_id, 
user_name) values(1,1), sharding use 2 decocrators according to 2 tables trying 
to decorate the insert sql.Maybe the decorator of table t_user_bill should not 
be used to the t_user_info's insert sql.
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   exception occur etc.
   1.I create table t_user_info,t_user_bill seperately in two database.
   CREATE TABLE "t_user_info" (
     "p_id" int8 NOT NULL,
     "user_name" int4,
     CONSTRAINT "t_user_info_pkey" PRIMARY KEY ("p_id")
   );
   CREATE TABLE "t_user_bill" (
     "p_id" int8 NOT NULL,
     "user_name" int4,
     "bill_no" int4,
     CONSTRAINT "t_user_bill_pkey" PRIMARY KEY ("p_id")
   );
   
   2.I import sharding jdbc, configure 2 tables sharding route/rules ,and use a 
Configuration class to create a sharding jdbc datasource.
   3.I construct a query sql, and a insert sql of table t_user_info.
   
![image](https://github.com/user-attachments/assets/3f07e963-8865-4293-a0a0-089b324ad033)
   4.The query sql is OK,but the insert sql is failed.
   
   5.when sharding jdbc create rewrite context in class “SQLRewriteEntry”,it 
use 2 decorator separately to 2 tables to change the insert sql, then create 2 
“ShardingInsertValuesTokenGenerator” in class “ShardingTokenGenerateBuilder”。
   6.when build the rewrited insert sql in class “AbstractSQLBuilder”,there are 
two value tokens,when getting conjuncation char between the two value tokens 
from sql,“subString”method occurs access index out of range error.
   Error happened in method “getConjunctionText”
   ### Example codes for reproduce this issue (such as a github link).
   


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