taojintianxia opened a new issue #5212: can not insert into proxy
URL: https://github.com/apache/incubator-shardingsphere/issues/5212
 
 
   ## Question
   
   before I create this issue ,  gooled the corresponding question, but I 
didn't get anything useful. I knew yonglun is the expert of proxy, so I assined 
this issue to your directly @tuohai666
   
   I tried to migrate a mysql database `test` to shardingsphere by 
`sharding-scaling` , but I got following exception : 
   
   ```
   Caused by: java.sql.SQLException: 2Unknown exception: [No signature of 
method: java.lang.String.mod() is applicable for argument types: 
(java.lang.Integer) values: [2]
   Possible solutions: drop(int), find(), any(), find(groovy.lang.Closure), 
find(java.lang.CharSequence), is(java.lang.Object)]
   ```
   
   I tried to debug the code , it triggered during  an insert clause, so I copy 
the insert sql and execute it in a mysql client as following :
   
   ```
   mysql> INSERT INTO `t_order`(`id`,`user_id`) VALUES(3,`103`);
   ERROR 10002 (C1000): 2Unknown exception: 
[org.apache.shardingsphere.sql.parser.sql.segment.dml.column.ColumnSegment 
cannot be cast to 
org.apache.shardingsphere.sql.parser.sql.segment.dml.expr.ExpressionSegment]
   ```
   
   the insert clause is generated by sharding-scaling. and following is one of 
the sharding table structure created by proxy : 
   
   ```
   CREATE TABLE `t_order_0` (
     `id` int(11) NOT NULL,
     `user_id` varchar(12) DEFAULT NULL,
     PRIMARY KEY (`id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=latin1
   ```
   
   followings are the my `config-sharding.yaml`
   
   ```
   schemaName: sharding_db
   
   dataSources:
    ds_0:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
      username: root
      password: root
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      maxLifetimeMilliseconds: 1800000
      maxPoolSize: 50
    ds_1:
      url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
      username: root
      password: root
      connectionTimeoutMilliseconds: 30000
      idleTimeoutMilliseconds: 60000
      maxLifetimeMilliseconds: 1800000
      maxPoolSize: 50
   
   shardingRule:
    tables:
      t_order:
        actualDataNodes: ds_${0..1}.t_order_${0..1}
        tableStrategy:
          inline:
            shardingColumn: order_id
            algorithmExpression: t_order_${order_id % 2}
        keyGenerator:
          type: SNOWFLAKE
          column: order_id
    bindingTables:
      - t_order
    defaultDatabaseStrategy:
      inline:
        shardingColumn: user_id
        algorithmExpression: ds_${user_id % 2}
    defaultTableStrategy:
      none:
   ```
   I found something I don't quite understand , that's when I try to insert the 
data by following , it works. I just cut of the ``` symbol
   
   ```
    INSERT INTO `t_order`(`id`,`user_id`) VALUES(3,103);
   ```
   I don't think It's a bug, just I don't uses it correctly . please guide me 
or give me some tips to solve this . 
   
   thanks in advance.
   
   BTW It likes the issue 
(4460)[https://github.com/apache/incubator-shardingsphere/issues/4460], but I 
can't change the insert clause because it generated by sharding-scaling .
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to