Skip to content

Commit

Permalink
fix unnamed alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro-KX committed Aug 6, 2024
1 parent f11b479 commit d607c8f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import { KdbResultsViewProvider } from "./services/resultsPanelProvider";
import {
checkLocalInstall,
checkOpenSslInstalled,
fixUnnamedAlias,
getInsights,
getServers,
initializeLocalServers,
Expand Down Expand Up @@ -146,6 +147,8 @@ export async function activate(context: ExtensionContext) {
"datasource",
);

fixUnnamedAlias();

commands.executeCommand("setContext", "kdb.QHOME", env.QHOME);

window.registerTreeDataProvider("kdb-servers", ext.serverProvider);
Expand Down
40 changes: 40 additions & 0 deletions src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,46 @@ export function getServers(): Server | undefined {
return workspace.getConfiguration().get("kdb.servers");
}

// TODO: Remove this on 1.9.0 release
/* istanbul ignore next */
export function fixUnnamedAlias(): void {
const servers = getServers();
const insights = getInsights();
let counter = 1;

if (servers) {
const updatedServers: Server = {};
for (const key in servers) {
if (servers.hasOwnProperty(key)) {
const server = servers[key];
if (server.serverAlias === "") {
server.serverAlias = `unnamedServer-${counter}`;
counter++;
}
updatedServers[server.serverAlias] = server;
}
}
updateServers(updatedServers);
ext.serverProvider.refresh(servers);
}

if (insights) {
const updatedInsights: Insights = {};
for (const key in insights) {
if (insights.hasOwnProperty(key)) {
const insight = insights[key];
if (insight.alias === "") {
insight.alias = `unnamedServer-${counter}`;
counter++;
}
updatedInsights[insight.alias] = insight;
}
}
updateInsights(updatedInsights);
ext.serverProvider.refreshInsights(insights);
}
}

export function getHideDetailedConsoleQueryOutput(): void {
const setting = workspace
.getConfiguration()
Expand Down

0 comments on commit d607c8f

Please sign in to comment.