Skip to content

Commit

Permalink
Merge pull request #180 from KxSystems/KXI-31288
Browse files Browse the repository at this point in the history
KX_31288 - KDB Results gives incorrect sort ordering
  • Loading branch information
Philip-Carneiro-KX authored Nov 6, 2023
2 parents ddee285 + 5925771 commit 6a42b7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/services/resultsPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
return !!this._view?.visible;
}

sanitizeString(str: string | string[]): string {
if (str instanceof Array) {
str = str.join(" ");
sanitizeString(value: any): any {
if (value instanceof Array) {
value = value.join(" ");
}
str = str.toString();
str = str.trim();
str = str.replace(/['"`]/g, "");
str = str.replace(/\$\{/g, "");
return str;
if (!isNaN(value)) {
return value;
}
value = value.toString();
value = value.trim();
value = value.replace(/['"`]/g, "");
value = value.replace(/\$\{/g, "");
return value;
}

defineAgGridTheme(): string {
Expand Down
10 changes: 9 additions & 1 deletion test/suite/panels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ describe("WebPanels", () => {
const actualString = resultsPanel.sanitizeString(inputString);
assert.strictEqual(actualString, expectedString);
});

it("should return a number", () => {
const inputString = 123;
const expectedString = 123;
const actualString = resultsPanel.sanitizeString(inputString);
assert.strictEqual(actualString, expectedString);
assert.ok(typeof actualString === "number");
});
});

describe("isVisible()", () => {
Expand Down Expand Up @@ -249,7 +257,7 @@ describe("WebPanels", () => {
{ id: 1, test: "test1" },
{ id: 2, test: "test2" },
];
const expectedOutput = `"rowData":[{"id":"1","test":"test1"},{"id":"2","test":"test2"}],"columnDefs":[{"field":"id","headerName":"id"},{"field":"test","headerName":"test"}]`;
const expectedOutput = `"rowData":[{"id":1,"test":"test1"},{"id":2,"test":"test2"}],"columnDefs":[{"field":"id","headerName":"id"},{"field":"test","headerName":"test"}]`;
const actualOutput = resultsPanel["_getWebviewContent"](input);
assert.strictEqual(typeof actualOutput, "string");
assert.ok(actualOutput.includes(expectedOutput));
Expand Down

0 comments on commit 6a42b7a

Please sign in to comment.