From bfb8536aa632371a4272c6f36df134f912db19dc Mon Sep 17 00:00:00 2001 From: Barbara Valdez <34872381+barbaravaldez@users.noreply.github.com> Date: Tue, 11 Jul 2023 11:07:09 -0700 Subject: [PATCH] Fix error when trying to update server or database properties (#23695) --- extensions/mssql/src/objectManagement/commands.ts | 2 +- extensions/mssql/src/objectManagement/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/mssql/src/objectManagement/commands.ts b/extensions/mssql/src/objectManagement/commands.ts index bc91a73b33..d720216593 100644 --- a/extensions/mssql/src/objectManagement/commands.ts +++ b/extensions/mssql/src/objectManagement/commands.ts @@ -124,7 +124,7 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore return; } try { - const parentUrn = context.nodeInfo ? await getParentUrn(context) : undefined; + const parentUrn = context.isConnectionNode ? undefined : await getParentUrn(context); const objectType = context.nodeInfo ? context.nodeInfo.nodeType as ObjectManagement.NodeType : (context.connectionProfile.databaseName === '' ? ObjectManagement.NodeType.Server : ObjectManagement.NodeType.Database); const objectName = context.nodeInfo ? context.nodeInfo.label : (!context.connectionProfile.databaseName ? context.connectionProfile.serverName : context.connectionProfile.databaseName); const objectUrn = context.nodeInfo ? context.nodeInfo!.metadata!.urn : (context.connectionProfile.databaseName === '' ? 'Server' : `Server/Database[@Name='${escapeSingleQuotes(context.connectionProfile.databaseName)}']`); diff --git a/extensions/mssql/src/objectManagement/utils.ts b/extensions/mssql/src/objectManagement/utils.ts index ef68617d54..9d56f9cb9a 100644 --- a/extensions/mssql/src/objectManagement/utils.ts +++ b/extensions/mssql/src/objectManagement/utils.ts @@ -11,7 +11,7 @@ import * as localizedConstants from './localizedConstants'; export async function refreshParentNode(context: azdata.ObjectExplorerContext): Promise { if (context) { try { - const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo!.nodePath); + const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo?.nodePath); const parentNode = await node?.getParent(); await parentNode?.refresh(); } @@ -24,7 +24,7 @@ export async function refreshParentNode(context: azdata.ObjectExplorerContext): export async function refreshNode(context: azdata.ObjectExplorerContext): Promise { if (context) { try { - const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo!.nodePath); + const node = await azdata.objectexplorer.getNode(context.connectionProfile!.id, context.nodeInfo?.nodePath); await node?.refresh(); } catch (err) {