You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/04/20 09:11:11 UTC
[shardingsphere] branch master updated: Modify the test case configuration file (#16916, #16933) (#16941)
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 999d7862163 Modify the test case configuration file (#16916, #16933) (#16941)
999d7862163 is described below
commit 999d7862163a4fdc7662d31fe51c314f0e0b1c34
Author: 本宫在,尔等都是妃 <11...@qq.com>
AuthorDate: Wed Apr 20 17:11:01 2022 +0800
Modify the test case configuration file (#16916, #16933) (#16941)
* Modify the test case configuration file (#16916, #16933)
* Fix: defaultShardingColumn does not take effect (#16933)
* Restore the configuration
* Fix: defaultShardingColumn does not take effect (#16933)
* Fix: defaultShardingColumn does not take effect (#16933)
* Fix: defaultShardingColumn does not take effect (#16933)
Co-authored-by: qubo <“doveylovey@126.com”>
---
.../src/main/resources/META-INF/sharding-databases-range.yaml | 1 +
.../main/resources/META-INF/sharding-hint-databases-tables.yaml | 9 +++++++++
.../org/apache/shardingsphere/sharding/rule/ShardingRule.java | 7 ++++---
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
index 113113b719d..ffa415821c5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases-range.yaml
@@ -58,6 +58,7 @@ rules:
- t_address
defaultDatabaseStrategy:
standard:
+ shardingColumn: user_id
shardingAlgorithmName: standard-test-db
defaultTableStrategy:
none:
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-hint-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-hint-databases-tables.yaml
index 54d35c897d6..cc4f1945b54 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-hint-databases-tables.yaml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-hint-databases-tables.yaml
@@ -45,6 +45,15 @@ rules:
keyGeneratorName: snowflake
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
+ databaseStrategy:
+ hint:
+ shardingAlgorithmName: hint-test
+ tableStrategy:
+ hint:
+ shardingAlgorithmName: hint-test
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
bindingTables:
- t_order,t_order_item
broadcastTables:
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 ae7d3332c60..4d989c38492 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
@@ -279,13 +279,14 @@ public final class ShardingRule implements SchemaRule, DataNodeContainedRule, Ta
}
private String getShardingColumn(final ShardingStrategyConfiguration shardingStrategyConfig) {
+ String shardingColumn = defaultShardingColumn;
if (shardingStrategyConfig instanceof ComplexShardingStrategyConfiguration) {
- return ((ComplexShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumns();
+ shardingColumn = ((ComplexShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumns();
}
if (shardingStrategyConfig instanceof StandardShardingStrategyConfiguration) {
- return ((StandardShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumn();
+ shardingColumn = ((StandardShardingStrategyConfiguration) shardingStrategyConfig).getShardingColumn();
}
- return StringUtils.defaultString(defaultShardingColumn, "");
+ return StringUtils.defaultString(shardingColumn, "");
}
@Override