You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/01 05:52:25 UTC

[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #18108: Fix `SHOW SHARDING TABLE RULES USED ALGORITHM` not display tables used default strategy.

RaigorJiang commented on code in PR #18108:
URL: https://github.com/apache/shardingsphere/pull/18108#discussion_r886340471


##########
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShardingTableRulesUsedAlgorithmQueryResultSet.java:
##########
@@ -49,14 +49,20 @@ private void requireResult(final ShowShardingTableRulesUsedAlgorithmStatement st
         if (!statement.getAlgorithmName().isPresent()) {
             return;
         }
+        String algorithmName = statement.getAlgorithmName().get();
+        boolean matchDefaultDatabaseShardingStrategy = null != shardingRuleConfig.getDefaultDatabaseShardingStrategy()
+                && algorithmName.equals(shardingRuleConfig.getDefaultDatabaseShardingStrategy().getShardingAlgorithmName());
+        boolean matchDefaultTableShardingStrategy = null != shardingRuleConfig.getDefaultTableShardingStrategy()
+                && algorithmName.equals(shardingRuleConfig.getDefaultTableShardingStrategy().getShardingAlgorithmName());
         shardingRuleConfig.getTables().forEach(each -> {
-            if (((null != each.getDatabaseShardingStrategy() && statement.getAlgorithmName().get().equals(each.getDatabaseShardingStrategy().getShardingAlgorithmName())))
-                    || (null != each.getTableShardingStrategy() && statement.getAlgorithmName().get().equals(each.getTableShardingStrategy().getShardingAlgorithmName()))) {
+            if (((null != each.getDatabaseShardingStrategy() && algorithmName.equals(each.getDatabaseShardingStrategy().getShardingAlgorithmName())))
+                    || (null != each.getTableShardingStrategy() && algorithmName.equals(each.getTableShardingStrategy().getShardingAlgorithmName()))
+                    || (null == each.getDatabaseShardingStrategy() && null == each.getTableShardingStrategy() && (matchDefaultDatabaseShardingStrategy || matchDefaultTableShardingStrategy))) {

Review Comment:
   `databaseShardingStrategy` and `tableShardingStrategy` are not necessarily null at the same time.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org