Skip to content

Commit

Permalink
Add "View authorities" option on SQL objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
dferrand committed Nov 24, 2024
1 parent 5e4bd83 commit 9d77129
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/views/schemaBrowser/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
"title": "Set filter",
"category": "Db2 for i",
"icon": "$(search)"
},
{
"command": "vscode-db2i.viewAuthorities",
"title": "View authorities",
"category": "Db2 for i"
}
],
"menus": {
Expand Down Expand Up @@ -177,6 +182,11 @@
"when": "viewItem == table || viewItem == view || viewItem == index",
"group": "db2data@4"
},
{
"command": "vscode-db2i.viewAuthorities",
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
"group": "db2data@5"
},
{
"command": "vscode-db2i.advisedIndexes",
"when": "viewItem == table || viewItem == schema",
Expand Down
16 changes: 16 additions & 0 deletions src/views/schemaBrowser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ export default class schemaBrowser {
}
}),

vscode.commands.registerCommand(`vscode-db2i.viewAuthorities`, async (object: SQLObject) => {
if (object) {
const content = `SELECT AUTHORIZATION_NAME, OBJECT_AUTHORITY,
OWNER, OBJECT_OPERATIONAL, OBJECT_MANAGEMENT, OBJECT_EXISTENCE, OBJECT_ALTER, OBJECT_REFERENCE,
DATA_READ, DATA_ADD, DATA_UPDATE, DATA_DELETE, DATA_EXECUTE FROM QSYS2.OBJECT_PRIVILEGES
WHERE OBJECT_SCHEMA='${object.schema}' AND OBJECT_NAME='${object.name}' AND
SQL_OBJECT_TYPE='${object.type.toUpperCase()}'`;

vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, {
content,
qualifier: `statement`,
open: false,
});
}
}),

vscode.commands.registerCommand(`vscode-db2i.getMTIs`, async (object: SQLObject|SchemaItem) => {
if (object) {
const content = getMTIStatement(object.schema, (`name` in object ? object.name : undefined));
Expand Down

0 comments on commit 9d77129

Please sign in to comment.