Skip to content

Commit 7406426

Browse files
Merge pull request #472 from KxSystems/v.1.9.1-dev-to-main
V.1.9.1 dev to main
2 parents ffdb610 + 9f1b884 commit 7406426

File tree

8 files changed

+95
-9
lines changed

8 files changed

+95
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the **kdb VS Code extension** are documented in this file.
44

5+
# v1.9.1
6+
7+
### Fixes
8+
9+
- Fixed Insights version validation
10+
511
# v1.9.0
612

713
### Enhancements

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "kdb",
44
"description": "IDE support for kdb product suite including the q programming language",
55
"publisher": "KX",
6-
"version": "1.9.0",
6+
"version": "1.9.1",
77
"engines": {
88
"vscode": "^1.86.0"
99
},

src/classes/insightsConnection.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { JwtUser } from "../models/jwt_user";
2929
import { Telemetry } from "../utils/telemetryClient";
3030
import { handleScratchpadTableRes, handleWSResults } from "../utils/queryUtils";
3131
import {
32+
compareVersions,
3233
invalidUsernameJWT,
3334
kdbOutputLog,
3435
tokenUndefinedError,
@@ -170,7 +171,7 @@ export class InsightsConnection {
170171
};
171172
// uncomment this WHEN the insights version is available
172173
// if (this.insightsVersion) {
173-
// if (this.insightsVersion >= 1.12) {
174+
// if (compareVersions(this.insightsVersion, 1.12)) {
174175
// this.connEndpoints = {
175176
// scratchpad: {
176177
// scratchpad: "scratchpad/execute/display",
@@ -432,7 +433,7 @@ export class InsightsConnection {
432433
};
433434

434435
if (this.insightsVersion) {
435-
if (this.insightsVersion >= 1.12) {
436+
if (compareVersions(this.insightsVersion, 1.12)) {
436437
body.returnFormat = isTableView ? "structuredText" : "text";
437438
} else {
438439
body.isTableView = isTableView;
@@ -476,7 +477,10 @@ export class InsightsConnection {
476477
kdbOutputLog(`[SCRATCHPAD] Status: ${response.status}`, "INFO");
477478
if (!response.data.error) {
478479
if (isTableView) {
479-
if (this.insightsVersion && this.insightsVersion >= 1.12) {
480+
if (
481+
this.insightsVersion &&
482+
compareVersions(this.insightsVersion, 1.12)
483+
) {
480484
response.data = JSON.parse(
481485
response.data.data,
482486
) as StructuredTextResults;

src/services/connectionManagerService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Telemetry } from "../utils/telemetryClient";
1919
import { InsightsConnection } from "../classes/insightsConnection";
2020
import { sanitizeQuery } from "../utils/queryUtils";
2121
import {
22+
compareVersions,
2223
getInsights,
2324
getKeyForServerName,
2425
getServerName,
@@ -353,7 +354,7 @@ export class ConnectionManagementService {
353354

354355
if (
355356
ext.activeConnection.insightsVersion &&
356-
ext.activeConnection.insightsVersion >= 1.12
357+
compareVersions(ext.activeConnection.insightsVersion, 1.12)
357358
) {
358359
const confirmationPrompt = `Are you sure you want to reset the scratchpad from the connection ${ext.activeConnection.connLabel}?`;
359360
const selection = await window.showInformationMessage(

src/services/resultsPanelProvider.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ext } from "../extensionVariables";
2323
import * as utils from "../utils/execution";
2424
import { getNonce } from "../utils/getNonce";
2525
import { getUri } from "../utils/getUri";
26-
import { kdbOutputLog } from "../utils/core";
26+
import { compareVersions, kdbOutputLog } from "../utils/core";
2727
import { StructuredTextResults } from "../models/queryResult";
2828

2929
export class KdbResultsViewProvider implements WebviewViewProvider {
@@ -226,7 +226,8 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
226226
convertToGrid(results: any, isInsights: boolean, connVersion?: number): any {
227227
let rowData = [];
228228
let columnDefs = [];
229-
if (connVersion && connVersion >= 1.12) {
229+
230+
if (connVersion && compareVersions(connVersion, 1.12)) {
230231
rowData = this.updatedExtractRowData(results);
231232
columnDefs = this.updatedExtractColumnDefs(results);
232233
} else {

src/utils/core.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,7 @@ function map(xs: any, f: any) {
694694
res.push(f.call(xs, xs[i], i));
695695
}
696696
}
697+
698+
export function compareVersions(version1: number, version2: number): boolean {
699+
return semver.gte(`${version1}.0`, `${version2}.0`);
700+
}

test/suite/panels.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,76 @@ describe("WebPanels", () => {
244244
stub.restore();
245245
});
246246

247+
it("should convert results to grid format for insights above 1.12", () => {
248+
const results: StructuredTextResults = {
249+
columns: [
250+
{
251+
name: "prop1",
252+
type: "type1",
253+
values: ["value1", "value2"],
254+
order: [1, 2],
255+
},
256+
{
257+
name: "prop2",
258+
type: "type2",
259+
values: ["value3", "value4"],
260+
order: [1, 2],
261+
},
262+
],
263+
count: 2,
264+
};
265+
266+
const expectedOutput = JSON.stringify({
267+
defaultColDef: {
268+
sortable: true,
269+
resizable: true,
270+
filter: true,
271+
flex: 1,
272+
minWidth: 100,
273+
},
274+
rowData: [
275+
{ index: 1, prop1: "value2", prop2: "value4" },
276+
{ index: 2 },
277+
],
278+
columnDefs: [
279+
{ field: "index", headerName: "Index", cellDataType: "number" },
280+
{
281+
field: "prop1",
282+
headerName: "prop1",
283+
cellDataType: "text",
284+
cellRendererParams: { disabled: false },
285+
headerTooltip: "type1",
286+
},
287+
{
288+
field: "prop2",
289+
headerName: "prop2",
290+
cellDataType: "text",
291+
cellRendererParams: { disabled: false },
292+
headerTooltip: "type2",
293+
},
294+
],
295+
domLayout: "autoHeight",
296+
pagination: true,
297+
paginationPageSize: 100,
298+
enableCellTextSelection: true,
299+
ensureDomOrder: true,
300+
suppressContextMenu: true,
301+
suppressDragLeaveHidesColumns: true,
302+
tooltipShowDelay: 200,
303+
loading: true,
304+
});
305+
306+
// Mock ext.connectionNode
307+
const stub = sinon.stub(ext, "activeConnection");
308+
stub.get(() => insightsConn);
309+
310+
const output = resultsPanel.convertToGrid(results, true, 1.12);
311+
assert.equal(JSON.stringify(output), expectedOutput);
312+
313+
// Restore the stub
314+
stub.restore();
315+
});
316+
247317
it("should convert results to grid format with empty rows", () => {
248318
const results = {
249319
data: {

0 commit comments

Comments
 (0)