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/05/15 12:11:30 UTC

[GitHub] [shardingsphere] wang7241 opened a new issue #5632: insert sql

wang7241 opened a new issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632


   ## 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 **more than 7 days** 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?
   4.0.0-RC1
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   ### Expected behavior
   When I insert some sql ,it can route some sharding table
   ### Actual behavior
   insert sql can not route some sharding table
   ### Reason analyze (If you can)
   Maybe be my insert sql have  "role" column
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   1.sharding rule configuration
   spring.shardingsphere.datasource.names = m1
   spring.shardingsphere.sharding.default-data-source-name = m1
   
   spring.shardingsphere.datasource.m1.type = com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.m1.driver-class-name = com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.m1.jdbc-url = jdbc:mysql://127.0.0.1/test?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&&useSSL=true
   spring.shardingsphere.datasource.m1.username = root
   spring.shardingsphere.datasource.m1.password = 123456
   
   spring.shardingsphere.sharding.tables.product_info.table-strategy.inline.sharding-column = product_info_id
   spring.shardingsphere.sharding.tables.product_info.table-strategy.inline.algorithm-expression = product_info_$->{product_info_id%2+1}
   2.sql
   insert into product_info(product_info_id,store_info_id,product_name,spec,region_code,price,role) values (#{productInfoId},#{storeInfoId},#{productName},#{spec},#{regionCode},#{price},#{role})
   2.
   ### Example codes for reproduce this issue (such as a github link).
   code is very easy ,as follow
   1.table   -----I create product_info_1 and product_info_2 they are construction is same
   SET NAMES utf8mb4;
   SET FOREIGN_KEY_CHECKS = 0;
   -- ----------------------------
   -- Table structure for product_info_1
   -- ----------------------------
   DROP TABLE IF EXISTS `product_info_1`;
   CREATE TABLE `product_info_1`  (
     `product_info_id` bigint(20) NOT NULL COMMENT 'id',
     `store_info_id` bigint(20) NULL DEFAULT NULL COMMENT '所属店铺id',
     `product_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品名称',
     `spec` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '规 格',
     `region_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产地',
     `price` decimal(10, 0) NULL DEFAULT NULL COMMENT '商品价格',
     `image_url` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品图片',
     PRIMARY KEY (`product_info_id`) USING BTREE,
     INDEX `FK_Reference_1`(`store_info_id`) USING BTREE
   ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
   SET FOREIGN_KEY_CHECKS = 1;
   2.entity
   @Data
   public class ProductInfo {
       private Long productInfoId;
       /**
        * 所属店铺id
        */
       private Long storeInfoId;
       /**
        * 商品名称
        */
       private String productName;
       /**
        * 规格
        */
       private String spec;
       /**
        * 产地
        */
       private String regionCode;
       /**
        * 商品价格
        */
       private BigDecimal price;
       /**
        * 商品图片
        */
       private String imageUrl;
       /**
        * 角色
        */
       private Integer role;
   }
   3.code
   @Mapper
   @Component
   public interface ProductDao {
       //添加商品基本信息
       @Insert("insert into product_info(product_info_id,store_info_id,product_name,spec,region_code,price,role) values (#{productInfoId},#{storeInfoId},#{productName},#{spec},#{regionCode},#{price},#{role})")
       @Options(useGeneratedKeys = true,keyProperty = "productInfoId",keyColumn = "product_info_id")
       int insertProductInfo(ProductInfo productInfo);}
   4.test
   @RunWith(SpringRunner.class)
   @SpringBootTest(classes = DemoApplication.class)
   class DemoApplicationTests {
       @Autowired
       ProductService productService;
       //添加商品
       @Test
       public void testCreateProduct(){
           for (int i=11;i<21;i++){
               ProductInfo productInfo = new ProductInfo();
               productInfo.setProductInfoId(2L);
               productInfo.setStoreInfoId(2L);//店铺id
               productInfo.setProductName("Java编程思想"+i);//商品名称
               productInfo.setSpec("大号");
               productInfo.setPrice(new BigDecimal(60));
               productInfo.setRegionCode("110100");
               productDao.insertProductInfo(productInfo);
           }
       }}


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-630529314


   > @ wang7241,您好:4.0.0-RC1是旧版本,您可以尝试使用最新发行版本`4.1.0`。
   
   I have changed the version to 4.1.0, but the problem still exists


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-634490027


   ok,no problem


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-629649805


   Hi @wang7241 , 4.0.0-RC1 is an old version, you can try the newest release version, `4.1.0`.


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-632594261


   > > > Hi @wang7241 , 4.0.0-RC1 is an old version, you can try the newest release version, `4.1.0`.
   > > 
   > > 
   > > Excuse me for my questions,I think it is common to have a "role" field in a table.Did your team ever have a problem with me
   > 
   > OK, I will try and reproduce this problem.
   
   Is there any good news?


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-640319719


   No,I dont, thank you for your help


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



[GitHub] [shardingsphere] wang7241 removed a comment on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 removed a comment on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633767495


   > Hi @wang7241 , I test this problem with `4.1.0` version, It's OK.
   > 
   > Can you create a github project, and submit test code which can reproduce this problem, Thanks.
   
   Now I use 4.1.0 to test my problem,there is a exception when I run my project,the exception as follow:
   ActualDataNodes must be configured if want to shard tables for logicTable [ku_challenge_rec]. it reminds me to configured ActualDataNodes,but my table "ku_challenge_rec" according to field "school_id" to dynamic devide tables. what should I do,please give me a help.On the other hand,when I used 4.0.0-RC1 there is no such exception.My springboot properties as follow:
   spring.shardingsphere.sharding.tables.ku_challenge_rec.table-strategy.inline.sharding-column = school_id
   spring.shardingsphere.sharding.tables.ku_challenge_rec.table-strategy.inline.algorithm-expression = ku_challenge_rec_$->{school_id}


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-630531628


   > Hi @wang7241 , 4.0.0-RC1 is an old version, you can try the newest release version, `4.1.0`.
   
    Excuse me for my  questions,I think it is common to have a "role" field in a table.Did your team ever have a problem with me


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



[GitHub] [shardingsphere] dongzl edited a comment on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl edited a comment on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633013302


   Hi @wang7241 , I have reproduce this problem, and I will fix it as soon as possible.


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-634374873






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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633019855


   Hi @wang7241 , I test this problem with `4.1.0` version, It's OK.
   
   Can you create a github project, and submit test code which can reproduce this problem, Thanks.


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-640319167


   Hi @wang7241 , Do you have any other questions?


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



[GitHub] [shardingsphere] wang7241 removed a comment on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 removed a comment on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-640319719


   No,I dont, thank you for your help


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633013302


   @wang7241 , I test this problem, but I don't reproduce it, I use the `4.1.0` version, It's OK.
   
   Can you create a github repository and make a project that can reproduce this problem, Thanks.


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-631184068


   > > Hi @wang7241 , 4.0.0-RC1 is an old version, you can try the newest release version, `4.1.0`.
   > 
   > Excuse me for my questions,I think it is common to have a "role" field in a table.Did your team ever have a problem with me
   
   OK, I will try and reproduce this problem.


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



[GitHub] [shardingsphere] dongzl commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-634564516


   ref: #3680  #3963


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-631184326


   > > > Hi @wang7241 , 4.0.0-RC1 is an old version, you can try the newest release version, `4.1.0`.
   > > 
   > > 
   > > Excuse me for my questions,I think it is common to have a "role" field in a table.Did your team ever have a problem with me
   > 
   > OK, I will try and reproduce this problem.
   
   Thank you very much


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



[GitHub] [shardingsphere] dongzl removed a comment on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
dongzl removed a comment on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633013302


   Hi @wang7241 , I have reproduce this problem, and I will fix it as soon as possible.


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-640319832


   > Hi @wang7241 , Do you have any other questions?
   
   No,I dont, thank you for your help


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



[GitHub] [shardingsphere] wang7241 commented on issue #5632: when insert sql have "role" column,sharding-jdbc can not route divided table

Posted by GitBox <gi...@apache.org>.
wang7241 commented on issue #5632:
URL: https://github.com/apache/shardingsphere/issues/5632#issuecomment-633765487






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