This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 ccf2485bda7 Adjust case of generated algorithm names (#16828)
ccf2485bda7 is described below
commit ccf2485bda7e5674d9831a5f4387c699695f40c7
Author: lanchengx <[email protected]>
AuthorDate: Fri Apr 15 17:42:28 2022 +0800
Adjust case of generated algorithm names (#16828)
* Adjust case of generated algorithm names.
* Adjust case of generated algorithm names.
* Update test.
---
.../handler/converter/ShardingTableRuleStatementConverter.java | 10 +++++-----
.../distsql/converter/ShardingRuleStatementConverterTest.java | 6 +++---
.../update/AlterShardingTableRuleStatementUpdaterTest.java | 4 ++--
.../update/CreateShardingTableRuleStatementUpdaterTest.java | 6 +++---
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/converter/ShardingTableRuleStatementConverter.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/converter/ShardingTableRuleStatementConverter.java
index 105edd43146..b17cebc22bf 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/converter/ShardingTableRuleStatementConverter.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/converter/ShardingTableRuleStatementConverter.java
@@ -105,7 +105,7 @@ public final class ShardingTableRuleStatementConverter {
* @return ShardingSphere algorithm configuration
*/
public static ShardingSphereAlgorithmConfiguration
createAlgorithmConfiguration(final AlgorithmSegment segment) {
- return new ShardingSphereAlgorithmConfiguration(segment.getName(),
segment.getProps());
+ return new
ShardingSphereAlgorithmConfiguration(segment.getName().toLowerCase(),
segment.getProps());
}
private static ShardingAutoTableRuleConfiguration
createAutoTableRuleConfiguration(final AutoTableRuleSegment rule) {
@@ -161,14 +161,14 @@ public final class ShardingTableRuleStatementConverter {
}
private static String getAutoTableShardingAlgorithmName(final String
tableName, final String algorithmType) {
- return String.format("%s_%s", tableName, algorithmType);
+ return String.format("%s_%s", tableName, algorithmType.toLowerCase());
}
private static String getTableShardingAlgorithmName(final String
tableName, final ShardingStrategyLevelType strategyLevel, final String
algorithmType) {
- return String.format("%s_%s_%s", tableName,
strategyLevel.name().toLowerCase(), algorithmType);
+ return String.format("%s_%s_%s", tableName,
strategyLevel.name().toLowerCase(), algorithmType.toLowerCase());
}
- private static String getKeyGeneratorName(final String tableName, final
String columnName) {
- return String.format("%s_%s", tableName, columnName);
+ private static String getKeyGeneratorName(final String tableName, final
String algorithmType) {
+ return String.format("%s_%s", tableName, algorithmType.toLowerCase());
}
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
index a5e42d2ca60..73fee31bc03 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/converter/ShardingRuleStatementConverterTest.java
@@ -64,14 +64,14 @@ public final class ShardingRuleStatementConverterTest {
ShardingAutoTableRuleConfiguration autoTableRule =
autoTableConfigIterator.next();
assertThat(autoTableRule.getLogicTable(), is("t_order"));
assertThat(autoTableRule.getActualDataSources(), is("ds0,ds1"));
-
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_MOD"));
+
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_mod"));
assertThat(tableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("t_order_snowflake"));
assertThat(tableRule.getKeyGenerateStrategy().getColumn(),
is("order_id"));
autoTableRule = autoTableConfigIterator.next();
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("snowflake_algorithm"));
assertThat(config.getShardingAlgorithms().size(), is(3));
-
assertThat(config.getShardingAlgorithms().get("t_order_MOD").getType(),
is("MOD"));
-
assertThat(config.getShardingAlgorithms().get("t_order_MOD").getProps().get("sharding_count"),
is("2"));
+
assertThat(config.getShardingAlgorithms().get("t_order_mod").getType(),
is("mod"));
+
assertThat(config.getShardingAlgorithms().get("t_order_mod").getProps().get("sharding_count"),
is("2"));
assertThat(config.getKeyGenerators().size(), is(1));
assertThat(config.getKeyGenerators().get("t_order_snowflake").getType(),
is("snowflake"));
assertThat(config.getKeyGenerators().get("t_order_snowflake").getProps().get(""),
is(""));
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
index f862c983104..d4d7d5e155d 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
@@ -107,7 +107,7 @@ public final class
AlterShardingTableRuleStatementUpdaterTest {
ShardingAutoTableRuleConfiguration autoTableRule =
currentRuleConfiguration.getAutoTables().iterator().next();
assertThat(autoTableRule.getLogicTable(), is("t_order_item"));
assertThat(autoTableRule.getActualDataSources(), is("ds_0,ds_1"));
-
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_item_MOD_TEST"));
+
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_item_mod_test"));
assertThat(((StandardShardingStrategyConfiguration)
autoTableRule.getShardingStrategy()).getShardingColumn(), is("order_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getColumn(),
is("product_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("t_order_item_snowflake_test"));
@@ -135,7 +135,7 @@ public final class
AlterShardingTableRuleStatementUpdaterTest {
ShardingAutoTableRuleConfiguration autoTableRule =
currentRuleConfiguration.getAutoTables().iterator().next();
assertThat(autoTableRule.getLogicTable(), is("t_order"));
assertThat(autoTableRule.getActualDataSources(), is("ds_0,ds_1"));
-
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_MOD_TEST"));
+
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_mod_test"));
assertThat(((StandardShardingStrategyConfiguration)
autoTableRule.getShardingStrategy()).getShardingColumn(), is("order_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getColumn(),
is("product_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("t_order_snowflake_test"));
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
index 9f5e5a965c6..55f8ad7e221 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
@@ -117,14 +117,14 @@ public final class
CreateShardingTableRuleStatementUpdaterTest {
ShardingAutoTableRuleConfiguration autoTableRule =
autoTableIterator.next();
assertThat(autoTableRule.getLogicTable(), is("t_order_item"));
assertThat(autoTableRule.getActualDataSources(), is("ds_0"));
-
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_MOD_TEST"));
+
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_mod_test"));
assertThat(((StandardShardingStrategyConfiguration)
autoTableRule.getShardingStrategy()).getShardingColumn(), is("order_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getColumn(),
is("product_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("product_id_snowflake_test"));
autoTableRule = autoTableIterator.next();
assertThat(autoTableRule.getLogicTable(), is("t_order_item_input"));
assertThat(autoTableRule.getActualDataSources(), is("logic_ds"));
-
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_item_input_MOD_TEST"));
+
assertThat(autoTableRule.getShardingStrategy().getShardingAlgorithmName(),
is("t_order_item_input_mod_test"));
assertThat(((StandardShardingStrategyConfiguration)
autoTableRule.getShardingStrategy()).getShardingColumn(), is("order_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getColumn(),
is("product_id"));
assertThat(autoTableRule.getKeyGenerateStrategy().getKeyGeneratorName(),
is("t_order_item_input_snowflake_test"));
@@ -168,7 +168,7 @@ public final class
CreateShardingTableRuleStatementUpdaterTest {
private ShardingAutoTableRuleConfiguration
createAutoTableRuleConfiguration() {
ShardingAutoTableRuleConfiguration result = new
ShardingAutoTableRuleConfiguration("t_order_item", "ds_0");
- result.setShardingStrategy(new
StandardShardingStrategyConfiguration("order_id", "t_order_MOD_TEST"));
+ result.setShardingStrategy(new
StandardShardingStrategyConfiguration("order_id", "t_order_mod_test"));
result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("product_id", "product_id_snowflake_test"));
return result;
}