mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Add vscode support for System database package references for SDK-style sql projects (#23383)
* changes for supporting system db package references in vscode * cleanup * address comments
This commit is contained in:
@@ -116,16 +116,27 @@ async function addSystemDatabaseReference(project: Project): Promise<ISystemData
|
||||
|
||||
const selectedSystemDb = await vscode.window.showQuickPick(
|
||||
getSystemDbOptions(project),
|
||||
{ title: constants.systemDatabase, ignoreFocusOut: true, });
|
||||
{ title: constants.systemDatabase, ignoreFocusOut: true });
|
||||
if (!selectedSystemDb) {
|
||||
// User cancelled
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 3. Prompt DB name
|
||||
const dbName = await promptDbName(selectedSystemDb);
|
||||
// 3 Prompt for Reference Type if it's an SDK-style project
|
||||
const referenceType = await promptReferenceType(project);
|
||||
if (referenceType === undefined) { // need to check for specifically undefined here because the enum SystemDbReferenceType.ArtifactReference evaluates to 0
|
||||
// User cancelled
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 4. Prompt suppress unresolved ref errors
|
||||
// 4. Prompt DB name
|
||||
const dbName = await promptDbName(selectedSystemDb);
|
||||
if (!dbName) {
|
||||
// User cancelled
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 5. Prompt suppress unresolved ref errors
|
||||
const suppressErrors = await promptSuppressUnresolvedRefErrors();
|
||||
|
||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||
@@ -136,7 +147,7 @@ async function addSystemDatabaseReference(project: Project): Promise<ISystemData
|
||||
databaseVariableLiteralValue: dbName,
|
||||
systemDb: getSystemDatabase(selectedSystemDb),
|
||||
suppressMissingDependenciesErrors: suppressErrors,
|
||||
systemDbReferenceType: SystemDbReferenceType.ArtifactReference
|
||||
systemDbReferenceType: referenceType
|
||||
};
|
||||
}
|
||||
|
||||
@@ -376,3 +387,21 @@ async function promptDbServerValues(location: string, defaultDbName: string): Pr
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
async function promptReferenceType(project: Project): Promise<SystemDbReferenceType | undefined> {
|
||||
let referenceType = SystemDbReferenceType.ArtifactReference;
|
||||
if (project.sqlProjStyle === ProjectType.SdkStyle) {
|
||||
const referenceTypeString = await vscode.window.showQuickPick(
|
||||
[constants.packageReference, constants.artifactReference],
|
||||
{ title: constants.referenceTypeRadioButtonsGroupTitle, ignoreFocusOut: true }
|
||||
);
|
||||
|
||||
if (referenceTypeString === undefined) { // need to check for specifically undefined here because the enum SystemDbReferenceType.ArtifactReference evaluates to 0
|
||||
return undefined;
|
||||
}
|
||||
|
||||
referenceType = referenceTypeString === constants.packageReference ? SystemDbReferenceType.PackageReference : SystemDbReferenceType.ArtifactReference;
|
||||
}
|
||||
|
||||
return referenceType;
|
||||
}
|
||||
|
||||
@@ -838,8 +838,9 @@ export class Project implements ISqlProject {
|
||||
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, referenceType, settings.databaseVariableLiteralValue);
|
||||
} else {
|
||||
systemDb = <unknown>settings.systemDb as vscodeMssql.SystemDatabase;
|
||||
referenceType = settings.systemDbReferenceType as vscodeMssql.SystemDbReferenceType;
|
||||
sqlProjService = this.sqlProjService as vscodeMssql.ISqlProjectsService;
|
||||
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, settings.databaseVariableLiteralValue);
|
||||
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, referenceType, settings.databaseVariableLiteralValue);
|
||||
}
|
||||
|
||||
if (!result.success && result.errorMessage) {
|
||||
|
||||
21
extensions/types/vscode-mssql.d.ts
vendored
21
extensions/types/vscode-mssql.d.ts
vendored
@@ -482,9 +482,10 @@ declare module 'vscode-mssql' {
|
||||
* @param projectUri Absolute path of the project, including .sqlproj
|
||||
* @param systemDatabase Type of system database
|
||||
* @param suppressMissingDependencies Whether to suppress missing dependencies
|
||||
* @param referenceType Type of reference - ArtifactReference or PackageReference
|
||||
* @param databaseLiteral Literal name used to reference another database in the same server, if not using SQLCMD variables
|
||||
*/
|
||||
addSystemDatabaseReference(projectUri: string, systemDatabase: SystemDatabase, suppressMissingDependencies: boolean, databaseLiteral?: string): Promise<ResultStatus>;
|
||||
addSystemDatabaseReference(projectUri: string, systemDatabase: SystemDatabase, suppressMissingDependencies: boolean, referenceType: SystemDbReferenceType, databaseLiteral?: string): Promise<ResultStatus>;
|
||||
|
||||
/**
|
||||
* Add a nuget package database reference to a project
|
||||
@@ -1112,7 +1113,7 @@ declare module 'vscode-mssql' {
|
||||
packageFilePath: string;
|
||||
databaseName: string;
|
||||
upgradeExisting: boolean;
|
||||
sqlCommandVariableValues?: Map<string, string>;
|
||||
sqlCommandVariableValues?: Record<string, string>;
|
||||
deploymentOptions?: DeploymentOptions;
|
||||
ownerUri: string;
|
||||
taskExecutionMode: TaskExecutionMode;
|
||||
@@ -1121,7 +1122,7 @@ declare module 'vscode-mssql' {
|
||||
export interface GenerateDeployScriptParams {
|
||||
packageFilePath: string;
|
||||
databaseName: string;
|
||||
sqlCommandVariableValues?: Map<string, string>;
|
||||
sqlCommandVariableValues?: Record<string, string>;
|
||||
deploymentOptions?: DeploymentOptions;
|
||||
ownerUri: string;
|
||||
taskExecutionMode: TaskExecutionMode;
|
||||
@@ -1153,7 +1154,7 @@ declare module 'vscode-mssql' {
|
||||
profilePath: string;
|
||||
databaseName: string;
|
||||
connectionString: string;
|
||||
sqlCommandVariableValues?: Map<string, string>;
|
||||
sqlCommandVariableValues?: Record<string, string>;
|
||||
deploymentOptions?: DeploymentOptions;
|
||||
}
|
||||
|
||||
@@ -1209,6 +1210,11 @@ declare module 'vscode-mssql' {
|
||||
* Type of system database
|
||||
*/
|
||||
systemDatabase: SystemDatabase;
|
||||
|
||||
/**
|
||||
* Type of reference - ArtifactReference or PackageReference
|
||||
*/
|
||||
referenceType: SystemDbReferenceType;
|
||||
}
|
||||
|
||||
export interface AddNugetPackageReferenceParams extends AddUserDatabaseReferenceParams {
|
||||
@@ -1249,6 +1255,13 @@ declare module 'vscode-mssql' {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface MoveFolderParams extends FolderParams {
|
||||
/**
|
||||
* Path of the folder, typically relative to the .sqlproj file
|
||||
*/
|
||||
destinationPath: string;
|
||||
}
|
||||
|
||||
export interface CreateSqlProjectParams extends SqlProjectParams {
|
||||
/**
|
||||
* Type of SQL Project: SDK-style or Legacy
|
||||
|
||||
Reference in New Issue
Block a user