AlbertTao edited a comment on issue #2101: Sharding-jdbc get different shardingValue between version 3.1.0 and version 2.0.3 when use a string type sharding column. URL: https://github.com/apache/incubator-shardingsphere/issues/2101#issuecomment-478517102 Result in InlineShardingStrategy.doSharding()  pom.xml dependency ```xml <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>sharding-jdbc-core</artifactId> <version>4.0.0.M1-SNAPSHOT</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.0.9</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.36</version> </dependency> ``` Java code ```java BufferedReader reader = new BufferedReader(new InputStreamReader(OrderTest.class .getResourceAsStream("/sharding-config-order-test.yaml"), "utf-8")); StringBuffer sb = new StringBuffer(); CharBuffer charBuffer = CharBuffer.allocate(32); for (int count = reader.read(charBuffer); count > 0; count = reader.read(charBuffer)) { sb.append(charBuffer.flip()); } DataSource dataSource = YamlShardingDataSourceFactory.createDataSource(sb.toString().getBytes("utf-8")); Connection connection = dataSource.getConnection(); Statement st = connection.createStatement(); ResultSet rs = st.executeQuery("select ts_order.* FROM ts_order where order_id='abcd'"); ``` sharding-config-order-test.yaml config ```yaml dataSources: ds_0: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/test_d_1 username: demo4 password: demo135 filters: stat initialSize: 2 maxActive: 80 maxWait: 5000 testOnBorrow: true testOnReturn: true testWhileIdle: true ds_1: !!com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/test_d_2 username: demo4 password: demo135 filters: stat initialSize: 2 maxActive: 80 maxWait: 5000 testOnBorrow: true testOnReturn: true testWhileIdle: true shardingRule: tables: ts_order: actualDataNodes: ds_${0..1}.ts_order_0${1..2} databaseStrategy: inline: shardingColumn: order_id algorithmExpression: ds_${order_id.hashCode() % 2} tableStrategy: inline: shardingColumn: order_id algorithmExpression: ts_order_0${order_id.hashCode() % 2 + 1} ```
---------------------------------------------------------------- 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
