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/10/25 02:37:03 UTC

[GitHub] [shardingsphere] wallacezhou commented on a diff in pull request #21722: authority type DATABASE_PERMITTED not apply correctly for some account when there are multi accounts #21615

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


##########
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:
   updated , please help to review it



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