From 96f345a74a0503eac5befcb593705f62efcc70f6 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Tue, 31 May 2022 16:33:27 -0400 Subject: [PATCH] add progress noticiations for database that would contain lots of tables (#19572) --- .../src/common/azureFunctionsUtils.ts | 15 ++++++++++++--- extensions/sql-bindings/src/common/constants.ts | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts index a6ce631a06..1b125364db 100644 --- a/extensions/sql-bindings/src/common/azureFunctionsUtils.ts +++ b/extensions/sql-bindings/src/common/azureFunctionsUtils.ts @@ -666,11 +666,20 @@ export async function promptSelectTable(connectionURI: string, bindingType: Bind // Create query to get list of tables from database selected let tableQuery = tablesQuery(selectedDatabase); const params = { ownerUri: connectionURI, queryString: tableQuery }; - // send SimpleExecuteRequest query to STS to get list of schema and tables based on the connection profile of the user - let queryResult: azureFunctionsContracts.SimpleExecuteResult = await vscodeMssqlApi.sendRequest(azureFunctionsContracts.SimpleExecuteRequest.type, params); + let queryResult: azureFunctionsContracts.SimpleExecuteResult | undefined; + // send SimpleExecuteRequest query to STS to get list of schema and tables based on the connection profile and database of the user + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: constants.tableListProgressTitle, + cancellable: false + }, async (_progress, _token) => { + queryResult = await vscodeMssqlApi.sendRequest(azureFunctionsContracts.SimpleExecuteRequest.type, params); + } + ); // Get schema and table names from query result rows - const tableNames = queryResult.rows.map(r => r[0].displayValue); + const tableNames = queryResult!.rows.map(r => r[0].displayValue); // add manual entry option to table names list for user to choose from as well (with pencil icon) let manuallyEnterObjectName = '$(pencil) ' + userObjectName; tableNames.unshift(manuallyEnterObjectName); diff --git a/extensions/sql-bindings/src/common/constants.ts b/extensions/sql-bindings/src/common/constants.ts index 9cde3d5b03..3c0f5b6cef 100644 --- a/extensions/sql-bindings/src/common/constants.ts +++ b/extensions/sql-bindings/src/common/constants.ts @@ -77,6 +77,7 @@ export const connectionProgressTitle = localize('connectionProgressTitle', "Test export const enterObjectName = localize('enterObjectName', 'Enter SQL table or view to query'); export const enterObjectNameToUpsert = localize('enterObjectNameToUpsert', 'Enter SQL table to upsert into'); export const selectTable = localize('selectTable', 'Select table to use'); +export const tableListProgressTitle = localize('tableListProgressTitle', "Fetching tables for selected database..."); export const selectConnectionError = (err?: any): string => err ? localize('selectConnectionError', "Failed to set connection string app setting: {0}", utils.getErrorMessage(err)) : localize('unableToSetConnectionString', "Failed to set connection string app setting"); export function selectBindingType(funcName?: string): string { return funcName ? localize('selectBindingTypeToSpecifiedFunction', "Select type of binding for the function '{0}'", funcName) : localize('selectBindingType', "Select type of binding"); } export function settingAlreadyExists(settingName: string): string { return localize('SettingAlreadyExists', 'Local app setting \'{0}\' already exists. Overwrite?', settingName); }