Skip to content

Commit

Permalink
Merge pull request #343 from KxSystems/main-hotfix-local-conn-1-5-1
Browse files Browse the repository at this point in the history
[KXI-47953]local conn main fix
  • Loading branch information
Philip-Carneiro-KX authored Jun 7, 2024
2 parents 0d9faf8 + ccc44ea commit 0a35590
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
5 changes: 3 additions & 2 deletions src/classes/localConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

import * as nodeq from "node-q";
import { window } from "vscode";
import { commands, window } from "vscode";
import { ext } from "../extensionVariables";
import { delay } from "../utils/core";
import { convertStringToArray, handleQueryResults } from "../utils/execution";
Expand Down Expand Up @@ -85,10 +85,11 @@ export class LocalConnection {
return;
}
conn.addListener("close", () => {
commands.executeCommand("kdb.disconnect", this.connLabel);
ext.outputChannel.appendLine(
`Connection stopped from ${this.options.host}:${this.options.port}`,
);
this.connected = false;
ext.outputChannel.show();
});

if (this.connection && this.connected) {
Expand Down
6 changes: 4 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ export async function activate(context: ExtensionContext) {
),
commands.registerCommand(
"kdb.disconnect",
async (viewItem: InsightsNode | KdbNode) => {
await disconnect(viewItem.label);
async (viewItem: InsightsNode | KdbNode | string) => {
const connLabel =
typeof viewItem === "string" ? viewItem : viewItem.label;
await disconnect(connLabel);
},
),
commands.registerCommand("kdb.addConnection", async () => {
Expand Down
13 changes: 3 additions & 10 deletions src/services/connectionManagerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,12 @@ export class ConnectionManagementService {
public disconnect(connLabel: string): void {
const connection = this.retrieveConnectedConnection(connLabel);
const connectionNode = this.retrieveConnection(connLabel);
if (!connection) {
if (!connection || !connectionNode) {
return;
}
const isLocal = connection instanceof LocalConnection;
/* istanbul ignore next */
if (isLocal && connectionNode) {
connection.getConnection()?.close(() => {
this.disconnectBehaviour(connection);
});
} else {
connection.disconnect();
this.disconnectBehaviour(connection);
}
connection.disconnect();
this.disconnectBehaviour(connection);
}

public async removeConnection(
Expand Down
11 changes: 5 additions & 6 deletions src/utils/executionConsole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ export class ExecutionConsole {
const hideDetails = ext.hideDetailedConsoleQueryOutput;
output = this.checkOutput(output, query);
let dataSourceRes: string[] = [];
if (type === undefined) {
this._console.show(true);
} else {
if (Array.isArray(output)) {
dataSourceRes = convertRowsToConsole(output);
}
this._console.show(true);

if (Array.isArray(output)) {
dataSourceRes = convertRowsToConsole(output);
}

if (!checkIfIsDatasource(type)) {
addQueryHistory(
query,
Expand Down
6 changes: 5 additions & 1 deletion test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ async function main() {
process.env["GENERATE_COVERAGE"] = "1";
}

await runTests({ extensionDevelopmentPath, extensionTestsPath });
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
version: "1.89.1",
});
} catch (err) {
console.log(err);
console.error("Failed to run tests.");
Expand Down

0 comments on commit 0a35590

Please sign in to comment.