mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 01:25:37 -05:00
fix sqlcmd variables not getting loaded correctly in vscode (#23103)
This commit is contained in:
@@ -159,9 +159,7 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
|
||||
}
|
||||
|
||||
// 4. Modify sqlcmd vars
|
||||
// If a publish profile is provided then the values from there will overwrite the ones in the
|
||||
// project file (if they exist)
|
||||
let sqlCmdVariables = Object.assign({}, project.sqlCmdVariables, publishProfile?.sqlCmdVariables);
|
||||
let sqlCmdVariables: Map<string, string> = getInitialSqlCmdVariables(project, publishProfile);
|
||||
|
||||
if (sqlCmdVariables.size > 0) {
|
||||
// Continually loop here, allowing the user to modify SQLCMD variables one
|
||||
@@ -170,13 +168,14 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
|
||||
// as many times as they wish - with an option to reset all the variables
|
||||
// to their starting values being provided as well.
|
||||
while (true) {
|
||||
const quickPickItems = Object.keys(sqlCmdVariables).map(key => {
|
||||
return {
|
||||
let quickPickItems = [];
|
||||
for (const key of sqlCmdVariables.keys()) {
|
||||
quickPickItems.push({
|
||||
label: key,
|
||||
description: sqlCmdVariables.get(key),
|
||||
key: key
|
||||
} as vscode.QuickPickItem & { key?: string, isResetAllVars?: boolean, isDone?: boolean };
|
||||
});
|
||||
} as vscode.QuickPickItem & { key?: string, isResetAllVars?: boolean, isDone?: boolean })
|
||||
}
|
||||
quickPickItems.push({ label: `$(refresh) ${constants.resetAllVars}`, isResetAllVars: true });
|
||||
quickPickItems.unshift({ label: `$(check) ${constants.done}`, isDone: true });
|
||||
const sqlCmd = await vscode.window.showQuickPick(
|
||||
@@ -200,7 +199,7 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
|
||||
sqlCmdVariables.set(sqlCmd.key, newValue);
|
||||
}
|
||||
} else if (sqlCmd.isResetAllVars) {
|
||||
sqlCmdVariables = Object.assign({}, project.sqlCmdVariables, publishProfile?.sqlCmdVariables);
|
||||
sqlCmdVariables = getInitialSqlCmdVariables(project, publishProfile);
|
||||
} else if (sqlCmd.isDone) {
|
||||
break;
|
||||
}
|
||||
@@ -220,6 +219,24 @@ export async function getPublishDatabaseSettings(project: ISqlProject, promptFor
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the sqlcmd variables from a sql projects. If a publish profile is provided then the values from there will overwrite the ones in the project file (if they exist)
|
||||
* @param project
|
||||
* @param publishProfile
|
||||
* @returns Map of sqlcmd variables
|
||||
*/
|
||||
function getInitialSqlCmdVariables(project: ISqlProject, publishProfile?: PublishProfile): Map<string, string> {
|
||||
// create a copy of the sqlcmd variable map so that the original ones don't get overwritten
|
||||
let sqlCmdVariables = new Map(project.sqlCmdVariables);
|
||||
if (publishProfile?.sqlCmdVariables) {
|
||||
for (const [key, value] of publishProfile.sqlCmdVariables) {
|
||||
sqlCmdVariables.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return sqlCmdVariables;
|
||||
}
|
||||
|
||||
export async function launchPublishTargetOption(project: Project): Promise<constants.PublishTargetType | undefined> {
|
||||
// Show options to user for deploy to existing server or docker
|
||||
const target = project.getProjectTargetVersion();
|
||||
|
||||
Reference in New Issue
Block a user