diff --git a/src/api/Tools.ts b/src/api/Tools.ts index 8afbab90c..74b3acee0 100644 --- a/src/api/Tools.ts +++ b/src/api/Tools.ts @@ -133,12 +133,12 @@ export namespace Tools { let realValue: string | number | null = strValue.trimEnd(); // is value a number? - if (strValue.startsWith(` `)) { + if (realValue.startsWith(` `)) { const asNumber = Number(strValue.trim()); if (!isNaN(asNumber)) { realValue = asNumber; } - } else if (strValue === `-`) { + } else if (realValue === `-`) { realValue = null; //null? } @@ -361,7 +361,7 @@ export namespace Tools { await vscode.commands.executeCommand(`setContext`, context, true); activeContexts.set(context, 0); } - else{ + else { activeContexts.set(context, stack++); } return await task(); @@ -369,13 +369,13 @@ export namespace Tools { finally { let stack = activeContexts.get(context); if (stack !== undefined) { - if(stack){ + if (stack) { activeContexts.set(context, stack--); } - else{ + else { await vscode.commands.executeCommand(`setContext`, context, undefined); activeContexts.delete(context); - } + } } } } diff --git a/src/testing/tools.ts b/src/testing/tools.ts index eaab959dc..11ceceaea 100644 --- a/src/testing/tools.ts +++ b/src/testing/tools.ts @@ -84,6 +84,47 @@ export const ToolsSuite: TestSuite = { assert.strictEqual(rows[0].CDTDUE, 0); } }, + { + name: `EN result set, empty columns`, test: async () => { + const lines = [ + `DB2>`, + `DB20000I THE SQL COMMAND COMPLETED SUCCESSFULLY.`, + `DB2>`, + `DB20000I THE SQL COMMAND COMPLETED SUCCESSFULLY.`, + `DB2>`, + ``, + `NAME TYPE ATTRIBUTE TEXT IS_SOURCE NB_MBR SOURCE_LENGTH CCSID `, + `---------- ----- ---------- -------------------------------------------------- ----------- ------- -------------- -------`, + `CMD *FILE *PHY 1 3 112 37 `, + `EVFTEMPF01 *FILE *PHY 1 2 112 37 `, + `EVFTEMPF02 *FILE *PHY 1 2 112 37 `, + `HEBREW *FILE *PHY 1 1 92 424 `, + `QCPYSRC *FILE *PHY 1 1 112 37 `, + `QDDSSRC *FILE *PHY 1 3 112 37 `, + `QRPGLEREF *FILE *PHY 1 1 112 37 `, + `QRPGLESRC *FILE *PHY cool mate 1 11 112 37 `, + `QSQDSRC *FILE *PHY SQL PROCEDURES 1 4 160 37 `, + `VSCODE *FILE *PHY 1 1 112 37 `, + ``, + ` 10 RECORD(S) SELECTED.`, + ``, + `DB2>`, + ] + + const rows = Tools.db2Parse(lines.join(`\n`)); + + assert.strictEqual(rows.length, 10); + + assert.strictEqual(rows[0].NAME, `CMD`); + assert.strictEqual(rows[0].TYPE, `*FILE`); + assert.strictEqual(rows[0].ATTRIBUTE, `*PHY`); + assert.strictEqual(rows[0].TEXT, ``); + assert.strictEqual(rows[0].IS_SOURCE, 1); + assert.strictEqual(rows[0].NB_MBR, 3); + assert.strictEqual(rows[0].SOURCE_LENGTH, 112); + assert.strictEqual(rows[0].CCSID, 37); + } + }, { name: `FR result set test`, test: async () => { const lines = [