Skip to content

Commit 9d77129

Browse files
committed
Add "View authorities" option on SQL objects.
1 parent 5e4bd83 commit 9d77129

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/views/schemaBrowser/contributes.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@
9595
"title": "Set filter",
9696
"category": "Db2 for i",
9797
"icon": "$(search)"
98+
},
99+
{
100+
"command": "vscode-db2i.viewAuthorities",
101+
"title": "View authorities",
102+
"category": "Db2 for i"
98103
}
99104
],
100105
"menus": {
@@ -177,6 +182,11 @@
177182
"when": "viewItem == table || viewItem == view || viewItem == index",
178183
"group": "db2data@4"
179184
},
185+
{
186+
"command": "vscode-db2i.viewAuthorities",
187+
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
188+
"group": "db2data@5"
189+
},
180190
{
181191
"command": "vscode-db2i.advisedIndexes",
182192
"when": "viewItem == table || viewItem == schema",

src/views/schemaBrowser/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,22 @@ export default class schemaBrowser {
162162
}
163163
}),
164164

165+
vscode.commands.registerCommand(`vscode-db2i.viewAuthorities`, async (object: SQLObject) => {
166+
if (object) {
167+
const content = `SELECT AUTHORIZATION_NAME, OBJECT_AUTHORITY,
168+
OWNER, OBJECT_OPERATIONAL, OBJECT_MANAGEMENT, OBJECT_EXISTENCE, OBJECT_ALTER, OBJECT_REFERENCE,
169+
DATA_READ, DATA_ADD, DATA_UPDATE, DATA_DELETE, DATA_EXECUTE FROM QSYS2.OBJECT_PRIVILEGES
170+
WHERE OBJECT_SCHEMA='${object.schema}' AND OBJECT_NAME='${object.name}' AND
171+
SQL_OBJECT_TYPE='${object.type.toUpperCase()}'`;
172+
173+
vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, {
174+
content,
175+
qualifier: `statement`,
176+
open: false,
177+
});
178+
}
179+
}),
180+
165181
vscode.commands.registerCommand(`vscode-db2i.getMTIs`, async (object: SQLObject|SchemaItem) => {
166182
if (object) {
167183
const content = getMTIStatement(object.schema, (`name` in object ? object.name : undefined));

0 commit comments

Comments
 (0)