You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "RaigorJiang (via GitHub)" <gi...@apache.org> on 2023/02/15 02:00:19 UTC

[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #24165: Make `ShowReadwriteSplittingRule`support query specified rule

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


##########
features/readwrite-splitting/distsql/handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutor.java:
##########
@@ -64,11 +64,15 @@ private void buildExportableMap(final ReadwriteSplittingRule rule) {
         exportableDataSourceMap = (Map<String, Map<String, String>>) exportedData.get(ExportableConstants.EXPORT_STATIC_READWRITE_SPLITTING_RULE);
     }
     
-    private Collection<LocalDataQueryResultRow> buildData(final ReadwriteSplittingRule rule) {
+    private Collection<LocalDataQueryResultRow> buildData(final ReadwriteSplittingRule rule, final ShowReadwriteSplittingRulesStatement sqlStatement) {
         Collection<LocalDataQueryResultRow> result = new LinkedList<>();
         ((ReadwriteSplittingRuleConfiguration) rule.getConfiguration()).getDataSources().forEach(each -> {
             LocalDataQueryResultRow dataItem = buildDataItem(each, getLoadBalancers((ReadwriteSplittingRuleConfiguration) rule.getConfiguration()));
-            result.add(dataItem);
+            if (null == sqlStatement.getRuleName()) {
+                result.add(dataItem);
+            } else if (sqlStatement.getRuleName().equalsIgnoreCase(each.getName())) {

Review Comment:
   I think it should be possible to combine these two if branches.



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