Skip to content

Commit

Permalink
Merge pull request #230 from KxSystems/KXI-35931
Browse files Browse the repository at this point in the history
KXI-35931 - Fix issue with execute local queries
  • Loading branch information
Philip-Carneiro-KX authored Jan 16, 2024
2 parents 7f5e8ae + 261226f commit 7b2f286
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/models/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class Connection {
public async executeQuery(
command: string,
context?: string,
stringify?: boolean
stringify?: boolean,
): Promise<any> {
await this.waitForConnection();

Expand All @@ -111,13 +111,13 @@ export class Connection {
if (err) {
this.result = handleQueryResults(
err.toString(),
QueryResultType.Error
QueryResultType.Error,
);
}
if (res) {
this.handleQueryResult(res);
}
}
},
);

const result = await this.waitForResult();
Expand All @@ -144,7 +144,7 @@ export class Connection {
if (res.errored) {
this.result = handleQueryResults(
res.error + (res.backtrace ? "\n" + res.backtrace : ""),
QueryResultType.Error
QueryResultType.Error,
);
} else {
this.result = res.result;
Expand All @@ -155,7 +155,9 @@ export class Connection {
while (this.result === undefined || this.result === null) {
await delay(500);
}
return this.result;
const result = this.result;
this.result = undefined;
return result;
}

public async executeQueryRaw(command: string): Promise<string> {
Expand Down Expand Up @@ -188,17 +190,17 @@ export class Connection {
ext.serverProvider.reload();

window.showErrorMessage(
`Connection to server ${this.options.host}:${this.options.port} failed! Details: ${err?.message}`
`Connection to server ${this.options.host}:${this.options.port} failed! Details: ${err?.message}`,
);
ext.outputChannel.appendLine(
`Connection to server ${this.options.host}:${this.options.port} failed! Details: ${err?.message}`
`Connection to server ${this.options.host}:${this.options.port} failed! Details: ${err?.message}`,
);
return;
}

conn.addListener("close", () => {
ext.outputChannel.appendLine(
`Connection stopped from ${this.options.host}:${this.options.port}`
`Connection stopped from ${this.options.host}:${this.options.port}`,
);
this.connected = false;
});
Expand All @@ -224,7 +226,7 @@ export class Connection {
this.connection?.k(globalQuery, (err, result) => {
if (err) {
window.showErrorMessage(
`Failed to retrieve kdb+ global variables: '${err.message}`
`Failed to retrieve kdb+ global variables: '${err.message}`,
);
return;
}
Expand Down Expand Up @@ -276,7 +278,7 @@ export class Connection {
this.connection?.k(reservedQuery, (err, result) => {
if (err) {
window.showErrorMessage(
`Failed to retrieve kdb+ reserved keywords: '${err.message}`
`Failed to retrieve kdb+ reserved keywords: '${err.message}`,
);
return;
}
Expand All @@ -288,7 +290,7 @@ export class Connection {
private onConnect(
err: Error | undefined,
conn: nodeq.Connection,
callback: nodeq.AsyncValueCallback<Connection>
callback: nodeq.AsyncValueCallback<Connection>,
): void {
this.connected = true;
this.connection = conn;
Expand Down

0 comments on commit 7b2f286

Please sign in to comment.