This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new cb30de84c71 fix invalid binding table issue. (#18182)
cb30de84c71 is described below
commit cb30de84c715950fd98c59c61f90b00273960cb2
Author: yumumu1988 <[email protected]>
AuthorDate: Mon Jun 6 08:01:27 2022 +0800
fix invalid binding table issue. (#18182)
when DataNodePrefix and shardingColumn are the same,
isValidShardingAlgorithm method returns false.
Co-authored-by: zhanghailin <[email protected]>
---
.../main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index 35c707036d3..4d63d170a47 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -347,7 +347,7 @@ public final class ShardingRule implements SchemaRule,
DataNodeContainedRule, Ta
String originAlgorithmExpression = null == shardingAlgorithm ? "" :
shardingAlgorithm.getProps().getProperty("algorithm-expression", "");
String sampleDataNodePrefix = databaseAlgorithm ?
tableRule.getDataSourceDataNode().getPrefix() :
tableRule.getTableDataNode().getPrefix();
String shardingColumn = getShardingColumn(shardingStrategyConfig,
checkedConfig.getDefaultShardingColumn());
- return originAlgorithmExpression.replace(sampleDataNodePrefix,
"").replace(shardingColumn, "").replaceAll(" ", "");
+ return originAlgorithmExpression.replaceFirst(sampleDataNodePrefix,
"").replaceFirst(shardingColumn, "").replaceAll(" ", "");
}
private String getShardingColumn(final ShardingStrategyConfiguration
shardingStrategyConfig, final String defaultShardingColumn) {