Skip to content

Commit f443439

Browse files
committed
Support for custom column list when RRN is used
Signed-off-by: worksofliam <[email protected]>
1 parent 312de70 commit f443439

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-db2i",
33
"displayName": "Db2 for IBM i",
44
"description": "Db2 for IBM i tools in VS Code",
5-
"version": "1.6.3-scott8",
5+
"version": "1.6.3-scott9",
66
"engines": {
77
"vscode": "^1.95.0"
88
},

src/views/results/resultSetPanelProvider.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,25 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
205205
}));
206206

207207
if (!currentColumns.some(c => c.useInWhere)) {
208+
const cName = ref.alias || `t`;
209+
210+
// Support for using a custom column list
211+
const selectClauseStart = basicSelect.toLowerCase().indexOf(`select `);
212+
const fromClauseStart = basicSelect.toLowerCase().indexOf(`from`);
213+
let possibleColumnList: string|undefined;
214+
215+
possibleColumnList = `${cName}.*`;
216+
if (fromClauseStart > 0) {
217+
possibleColumnList = basicSelect.substring(0, fromClauseStart);
218+
if (selectClauseStart >= 0) {
219+
possibleColumnList = possibleColumnList.substring(selectClauseStart + 7);
220+
221+
if (possibleColumnList.trim() === `*`) {
222+
possibleColumnList = `${cName}.*`;
223+
}
224+
}
225+
}
226+
208227
// We need to override the input statement if they want to do updatable
209228
const whereClauseStart = basicSelect.toLowerCase().indexOf(`where`);
210229
let fromWhereClause: string|undefined;
@@ -213,7 +232,8 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
213232
fromWhereClause = basicSelect.substring(whereClauseStart);
214233
}
215234

216-
basicSelect = `select rrn(t) as RRN, t.* from ${schema}.${ref.object.name} as t ${fromWhereClause || ``}`;
235+
236+
basicSelect = `select rrn(${cName}) as RRN, ${possibleColumnList} from ${schema}.${ref.object.name} as ${cName} ${fromWhereClause || ``}`;
217237
currentColumns = [{name: `RRN`, jsType: `number`, useInWhere: true}, ...currentColumns];
218238
}
219239

0 commit comments

Comments
 (0)