CrazyFz opened a new issue #8638:
URL: https://github.com/apache/shardingsphere/issues/8638
## Bug Report
When my just have one table, all database CRUD is right
but when i configure two tables(ssuser,gateway), it just can select ,but not
insert
then debug i find error, but do not how to fix it
My DataSourceTestConfig code
`
public class BeetlSqlDataSourceTestConfig {
@Autowired
private Environment e;
/**
* postgrepsql db 配置
* @return
*/
@Bean(destroyMethod = "close",value = "sstest")
DataSource getDataSource() {
HikariDataSource hs = new HikariDataSource();
hs.setUsername(e.getProperty("spring.datasource.hikari.sstest.username"));
hs.setJdbcUrl(e.getProperty("spring.datasource.hikari.sstest.url"));
hs.setPassword(e.getProperty("spring.datasource.hikari.sstest.password"));
hs.setDriverClassName(e.getProperty("spring.datasource.hikari.sstest.driver-class-name"));
Map<String, DataSource> dataSourceMap = new HashMap<>();
dataSourceMap.put("ds0", hs);
ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(getSsuserTableRuleConfiguration());
shardingRuleConfig.getTables().add(getGatewayTableRuleConfiguration());
Properties tableShardingAlgorithmrProps = new Properties();
tableShardingAlgorithmrProps.setProperty(
"algorithm-expression", "ssuser_${user_id}");
shardingRuleConfig.getShardingAlgorithms().put("tableShardingAlgorithm",
new ShardingSphereAlgorithmConfiguration("INLINE",
tableShardingAlgorithmrProps));
Properties tableShardingAlgorithmrProps2 = new Properties();
tableShardingAlgorithmrProps2.setProperty(
"algorithm-expression", "gateway_${user_id}");
shardingRuleConfig.getShardingAlgorithms().put("tableShardingAlgorithm",
new
ShardingSphereAlgorithmConfiguration("INLINE",
tableShardingAlgorithmrProps2));
DataSource dataSource = null;
try {
Properties dataSourceProperties = new Properties();
dataSourceProperties.put("sql-show", true);
dataSource =
ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
Collections.singleton(shardingRuleConfig), dataSourceProperties);
} catch (SQLException e1) {
e1.printStackTrace();
}
return dataSource;
}
private static ShardingTableRuleConfiguration
getSsuserTableRuleConfiguration() {
ShardingTableRuleConfiguration orderTableRuleConfig =
new ShardingTableRuleConfiguration("ssuser",
"ds0.ssuser_${0..1}");
orderTableRuleConfig.setTableShardingStrategy(
new StandardShardingStrategyConfiguration(
"user_id", "tableShardingAlgorithm"));
return orderTableRuleConfig;
}
private static ShardingTableRuleConfiguration
getGatewayTableRuleConfiguration() {
ShardingTableRuleConfiguration orderTableRuleConfig =
new ShardingTableRuleConfiguration("gateway",
"ds0.gateway_${0..1}");
orderTableRuleConfig.setTableShardingStrategy(
new StandardShardingStrategyConfiguration(
"user_id", "tableShardingAlgorithm"));
return orderTableRuleConfig;
}
`


my sql
`
CREATE TABLE `gateway_1` (
`user_id` int(11) NOT NULL,
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
)
CREATE TABLE `gateway_0` (
`user_id` int(11) NOT NULL,
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
)
CREATE TABLE `ssuser_0` (
`user_id` int(11) NOT NULL,
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
)
CREATE TABLE `ssuser_1` (
`user_id` int(11) NOT NULL,
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
)
`
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?
5.0.0-alpha
### Which project did you use?
ShardingSphere-JDBC
----------------------------------------------------------------
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]