Skip to content

Commit d4eda78

Browse files
committed
New API to get current schema
Signed-off-by: worksofliam <[email protected]>
1 parent 621860f commit d4eda78

File tree

4 files changed

+8
-50
lines changed

4 files changed

+8
-50
lines changed

package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,6 @@
429429
"category": "Db2 for i",
430430
"icon": "$(output)"
431431
},
432-
{
433-
"command": "vscode-db2i.setCurrentSchema",
434-
"title": "Set current schema",
435-
"category": "Db2 for i"
436-
},
437432
{
438433
"command": "vscode-db2i.setSchemaFilter",
439434
"title": "Set filter",
@@ -948,11 +943,6 @@
948943
}
949944
],
950945
"view/item/context": [
951-
{
952-
"command": "vscode-db2i.setCurrentSchema",
953-
"when": "viewItem == schema",
954-
"group": "db2@1"
955-
},
956946
{
957947
"command": "vscode-db2i.setSchemaFilter",
958948
"when": "viewItem == schema",

src/connection/sqlJob.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ export class OldSQLJob extends SQLJob {
1919
return this.selfState;
2020
}
2121

22-
getCurrentSchema(): string {
22+
async getCurrentSchema(): Promise<string> {
23+
if (this.getNaming() === `sql`) {
24+
const result = await this.execute<{'00001': string}>(`values (current schema)`);
25+
if (result.success && result.data.length > 0) {
26+
return result.data[0]['00001'];
27+
}
28+
}
29+
2330
return this.options.libraries[0] || `QGPL`;
2431
}
2532

@@ -178,19 +185,6 @@ export class OldSQLJob extends SQLJob {
178185
throw e;
179186
}
180187
}
181-
182-
async setCurrentSchema(schema: string): Promise<QueryResult<any>> {
183-
if (schema) {
184-
const upperSchema = Statement.delimName(schema, true);
185-
const result = await this.execute(`set current schema = ?`, {parameters: [upperSchema]});
186-
if (result.success) {
187-
this.options.libraries[0] = upperSchema;
188-
}
189-
190-
return result;
191-
192-
}
193-
}
194188

195189
getJobLog(): Promise<QueryResult<JobLogEntry>> {
196190
return this.query<JobLogEntry>(`select * from table(qsys2.joblog_info('*')) a`).execute();

src/views/schemaBrowser/contributes.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@
9595
"category": "Db2 for i",
9696
"icon": "$(output)"
9797
},
98-
{
99-
"command": "vscode-db2i.setCurrentSchema",
100-
"title": "Set current schema",
101-
"category": "Db2 for i"
102-
},
10398
{
10499
"command": "vscode-db2i.setSchemaFilter",
105100
"title": "Set filter",
@@ -127,11 +122,6 @@
127122
}
128123
],
129124
"view/item/context": [
130-
{
131-
"command": "vscode-db2i.setCurrentSchema",
132-
"when": "viewItem == schema",
133-
"group": "db2@1"
134-
},
135125
{
136126
"command": "vscode-db2i.setSchemaFilter",
137127
"when": "viewItem == schema",

src/views/schemaBrowser/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,6 @@ export default class schemaBrowser {
350350
}
351351
}),
352352

353-
vscode.commands.registerCommand(`vscode-db2i.setCurrentSchema`, async (node: SchemaItem) => {
354-
if (node && node.contextValue === `schema`) {
355-
const schema = node.schema.toUpperCase();
356-
357-
const config = getInstance().getConfig();
358-
const currentLibrary = config.currentLibrary.toUpperCase();
359-
360-
if (schema && schema !== currentLibrary) {
361-
config.currentLibrary = schema;
362-
await getInstance().setConfig(config);
363-
}
364-
365-
vscode.window.showInformationMessage(`Current schema set to ${schema}.`);
366-
}
367-
}),
368-
369353
vscode.commands.registerCommand(`vscode-db2i.setSchemaFilter`, async (node: SchemaItem) => {
370354
if (node) {
371355
const value = await vscode.window.showInputBox({

0 commit comments

Comments
 (0)