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 2021/04/23 15:38:40 UTC

[GitHub] [shardingsphere] zhujunxxxxx commented on a change in pull request #10148: Implement OraclePrivilegeHandler and add unit test

zhujunxxxxx commented on a change in pull request #10148:
URL: https://github.com/apache/shardingsphere/pull/10148#discussion_r619317414



##########
File path: shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
##########
@@ -81,15 +126,28 @@ private void assertPrivileges(final Map<ShardingSphereUser, NativePrivileges> ac
     private DataSource mockDataSource(final Collection<ShardingSphereUser> users) throws SQLException {
         ResultSet sysPrivilegeResultSet = mockSysPrivilegeResultSet();
         DataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);
-        String sysPrivilegeSql = "SELECT GRANTEE, PRIVILEGE, ADMIN_OPTION, INHERITED FROM DBA_SYS_PRIVS WHERE GRANTEE IN (%s)";
-        String userList = users.stream().map(item -> String.format("'%s'", item.getGrantee().getUsername(), item.getGrantee().getHostname())).collect(Collectors.joining(", "));
+        String sysPrivilegeSql = "SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE IN (%s)";
+        String userList = users.stream().map(item -> String.format("%s", item.getGrantee().getUsername())).collect(Collectors.joining(", "));

Review comment:
       same question about `'`

##########
File path: shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java
##########
@@ -151,12 +174,12 @@ private void collectSysPrivileges(final Map<ShardingSphereUser, List<PrivilegeTy
     }
     
     private String getSysPrivilegesSQL(final Collection<ShardingSphereUser> users) {
-        String userList = users.stream().map(each -> String.format("'%s'", each.getGrantee().getUsername())).collect(Collectors.joining(", "));
+        String userList = users.stream().map(each -> String.format("%s", each.getGrantee().getUsername())).collect(Collectors.joining(", "));

Review comment:
       we can't remove `'` symbol, the target sql is like `xxx in ('admin', 'sys', 'other')`, if you remove `'` the sql will grammar error.

##########
File path: shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandler.java
##########
@@ -151,12 +174,12 @@ private void collectSysPrivileges(final Map<ShardingSphereUser, List<PrivilegeTy
     }
     
     private String getSysPrivilegesSQL(final Collection<ShardingSphereUser> users) {
-        String userList = users.stream().map(each -> String.format("'%s'", each.getGrantee().getUsername())).collect(Collectors.joining(", "));
+        String userList = users.stream().map(each -> String.format("%s", each.getGrantee().getUsername())).collect(Collectors.joining(", "));
         return String.format(SYS_PRIVILEGE_SQL, userList);
     }
     
     private String getTablePrivilegesSQL(final Collection<ShardingSphereUser> users) {
-        String userList = users.stream().map(each -> String.format("'%s'", each.getGrantee().getUsername())).collect(Collectors.joining(", "));
+        String userList = users.stream().map(each -> String.format("%s", each.getGrantee().getUsername())).collect(Collectors.joining(", "));

Review comment:
       we can't remove `'` symbol, the target sql is like `xxx in ('admin', 'sys', 'other')`, if you remove `'` the sql will grammar error.




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

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