未验证 提交 afd1d2c2 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #8154 from Vlczech/devel2

Refactoring (simplification) grant/revoke command to avoid code repeating
......@@ -91,14 +91,16 @@ public class PostgreCommandGrantPrivilege extends DBECommandAbstract<PostgrePriv
} else {
objectType = PostgreUtils.getObjectTypeName(object);
}
String grantScript =
grant ?
(object instanceof PostgreTableColumn ?
"GRANT " + privName + "(" + DBUtils.getQuotedIdentifier(object) + ") ON " + ((PostgreTableColumn) object).getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " TO " + roleName :
"GRANT " + privName + " ON " + objectType + " " + objectName + " TO " + roleName) :
(object instanceof PostgreTableColumn ?
"REVOKE " + privName + "(" + DBUtils.getQuotedIdentifier(object) + ") ON " + ((PostgreTableColumn) object).getTable().getFullyQualifiedName(DBPEvaluationContext.DDL) + " FROM " + roleName :
"REVOKE " + privName + " ON " + objectType + " " + objectName + " FROM " + roleName);
String grantedCols = "", grantedTypedObject = "";
if (object instanceof PostgreTableColumn) {
grantedCols = "(" + DBUtils.getQuotedIdentifier(object) + ")";
grantedTypedObject = ((PostgreTableColumn) object).getTable().getFullyQualifiedName(DBPEvaluationContext.DDL);
} else {
grantedTypedObject = objectType + " " + objectName;
}
String grantScript = (grant ? "GRANT " : "REVOKE ") + privName + grantedCols + " ON " + grantedTypedObject + (grant ? " TO " : " FROM ") + roleName;
if (grant && withGrantOption) {
grantScript += " WITH GRANT OPTION";
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册