mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -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(
|
const selectedSystemDb = await vscode.window.showQuickPick(
|
||||||
getSystemDbOptions(project),
|
getSystemDbOptions(project),
|
||||||
{ title: constants.systemDatabase, ignoreFocusOut: true, });
|
{ title: constants.systemDatabase, ignoreFocusOut: true });
|
||||||
if (!selectedSystemDb) {
|
if (!selectedSystemDb) {
|
||||||
// User cancelled
|
// User cancelled
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Prompt DB name
|
// 3 Prompt for Reference Type if it's an SDK-style project
|
||||||
const dbName = await promptDbName(selectedSystemDb);
|
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();
|
const suppressErrors = await promptSuppressUnresolvedRefErrors();
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
@@ -136,7 +147,7 @@ async function addSystemDatabaseReference(project: Project): Promise<ISystemData
|
|||||||
databaseVariableLiteralValue: dbName,
|
databaseVariableLiteralValue: dbName,
|
||||||
systemDb: getSystemDatabase(selectedSystemDb),
|
systemDb: getSystemDatabase(selectedSystemDb),
|
||||||
suppressMissingDependenciesErrors: suppressErrors,
|
suppressMissingDependenciesErrors: suppressErrors,
|
||||||
systemDbReferenceType: SystemDbReferenceType.ArtifactReference
|
systemDbReferenceType: referenceType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,3 +387,21 @@ async function promptDbServerValues(location: string, defaultDbName: string): Pr
|
|||||||
}
|
}
|
||||||
return ret;
|
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);
|
result = await sqlProjService.addSystemDatabaseReference(this.projectFilePath, systemDb, settings.suppressMissingDependenciesErrors, referenceType, settings.databaseVariableLiteralValue);
|
||||||
} else {
|
} else {
|
||||||
systemDb = <unknown>settings.systemDb as vscodeMssql.SystemDatabase;
|
systemDb = <unknown>settings.systemDb as vscodeMssql.SystemDatabase;
|
||||||
|
referenceType = settings.systemDbReferenceType as vscodeMssql.SystemDbReferenceType;
|
||||||
sqlProjService = this.sqlProjService as vscodeMssql.ISqlProjectsService;
|
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) {
|
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 projectUri Absolute path of the project, including .sqlproj
|
||||||
* @param systemDatabase Type of system database
|
* @param systemDatabase Type of system database
|
||||||
* @param suppressMissingDependencies Whether to suppress missing dependencies
|
* @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
|
* @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
|
* Add a nuget package database reference to a project
|
||||||
@@ -1112,7 +1113,7 @@ declare module 'vscode-mssql' {
|
|||||||
packageFilePath: string;
|
packageFilePath: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
upgradeExisting: boolean;
|
upgradeExisting: boolean;
|
||||||
sqlCommandVariableValues?: Map<string, string>;
|
sqlCommandVariableValues?: Record<string, string>;
|
||||||
deploymentOptions?: DeploymentOptions;
|
deploymentOptions?: DeploymentOptions;
|
||||||
ownerUri: string;
|
ownerUri: string;
|
||||||
taskExecutionMode: TaskExecutionMode;
|
taskExecutionMode: TaskExecutionMode;
|
||||||
@@ -1121,7 +1122,7 @@ declare module 'vscode-mssql' {
|
|||||||
export interface GenerateDeployScriptParams {
|
export interface GenerateDeployScriptParams {
|
||||||
packageFilePath: string;
|
packageFilePath: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
sqlCommandVariableValues?: Map<string, string>;
|
sqlCommandVariableValues?: Record<string, string>;
|
||||||
deploymentOptions?: DeploymentOptions;
|
deploymentOptions?: DeploymentOptions;
|
||||||
ownerUri: string;
|
ownerUri: string;
|
||||||
taskExecutionMode: TaskExecutionMode;
|
taskExecutionMode: TaskExecutionMode;
|
||||||
@@ -1153,7 +1154,7 @@ declare module 'vscode-mssql' {
|
|||||||
profilePath: string;
|
profilePath: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
connectionString: string;
|
connectionString: string;
|
||||||
sqlCommandVariableValues?: Map<string, string>;
|
sqlCommandVariableValues?: Record<string, string>;
|
||||||
deploymentOptions?: DeploymentOptions;
|
deploymentOptions?: DeploymentOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,6 +1210,11 @@ declare module 'vscode-mssql' {
|
|||||||
* Type of system database
|
* Type of system database
|
||||||
*/
|
*/
|
||||||
systemDatabase: SystemDatabase;
|
systemDatabase: SystemDatabase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of reference - ArtifactReference or PackageReference
|
||||||
|
*/
|
||||||
|
referenceType: SystemDbReferenceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddNugetPackageReferenceParams extends AddUserDatabaseReferenceParams {
|
export interface AddNugetPackageReferenceParams extends AddUserDatabaseReferenceParams {
|
||||||
@@ -1249,6 +1255,13 @@ declare module 'vscode-mssql' {
|
|||||||
path: string;
|
path: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MoveFolderParams extends FolderParams {
|
||||||
|
/**
|
||||||
|
* Path of the folder, typically relative to the .sqlproj file
|
||||||
|
*/
|
||||||
|
destinationPath: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CreateSqlProjectParams extends SqlProjectParams {
|
export interface CreateSqlProjectParams extends SqlProjectParams {
|
||||||
/**
|
/**
|
||||||
* Type of SQL Project: SDK-style or Legacy
|
* Type of SQL Project: SDK-style or Legacy
|
||||||
|
|||||||
Reference in New Issue
Block a user