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


##########
proxy/backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandler.java:
##########
@@ -84,7 +86,12 @@ private String getFirstDatabaseName() {
         if (databaseNames.isEmpty()) {
             throw new NoDatabaseSelectedException();
         }
-        Optional<String> result = databaseNames.stream().filter(each -> 
ProxyContext.getInstance().getDatabase(each).containsDataSource()).findFirst();
+        AuthorityRule authorityRule = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(
+                AuthorityRule.class);
+        Optional<ShardingSpherePrivileges> privileges = 
authorityRule.findPrivileges(connectionSession.getGrantee());
+        Optional<String> result = privileges.isPresent() ? 
databaseNames.stream().filter(each -> privileges.get().hasPrivileges(each)

Review Comment:
   Hi @wallacezhou ,
   Welcome, your PR provides a working solution, but please don't do 
complicated logical operations in the ternary operator, can you extract the 
judgment condition as a variable?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to