Handle some server properties not being supported for certain SQL versions (#24587)

* Co-authored-by: Benjin Dubishar <benjind@microsoft.com>
This commit is contained in:
Cory Rivera
2023-10-09 13:28:08 -07:00
committed by GitHub
parent a3041f25b2
commit 63a78e62aa
7 changed files with 132 additions and 118 deletions

View File

@@ -1,6 +1,6 @@
{ {
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}", "downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "4.10.0.4", "version": "4.10.0.14",
"downloadFileNames": { "downloadFileNames": {
"Windows_86": "win-x86-net7.0.zip", "Windows_86": "win-x86-net7.0.zip",
"Windows_64": "win-x64-net7.0.zip", "Windows_64": "win-x64-net7.0.zip",

View File

@@ -544,7 +544,7 @@ export enum AffinityType {
} }
export interface Server extends ObjectManagement.SqlObject { export interface Server extends ObjectManagement.SqlObject {
hardwareGeneration: string; hardwareGeneration?: string;
language: string; language: string;
memoryInMB: number; memoryInMB: number;
operatingSystem: string; operatingSystem: string;
@@ -553,14 +553,14 @@ export interface Server extends ObjectManagement.SqlObject {
version: string; version: string;
isClustered: boolean; isClustered: boolean;
isHadrEnabled: boolean; isHadrEnabled: boolean;
isPolyBaseInstalled: boolean; isPolyBaseInstalled?: boolean;
isXTPSupported: boolean; isXTPSupported?: boolean;
product: string; product: string;
reservedStorageSizeMB: number; reservedStorageSizeMB?: number;
rootDirectory: string; rootDirectory: string;
serverCollation: string; serverCollation: string;
serviceTier: string; serviceTier?: string;
storageSpaceUsageInMB: number; storageSpaceUsageInMB?: number;
minServerMemory: NumericServerProperty; minServerMemory: NumericServerProperty;
maxServerMemory: NumericServerProperty; maxServerMemory: NumericServerProperty;
autoProcessorAffinityMaskForAll: boolean; autoProcessorAffinityMaskForAll: boolean;

View File

@@ -10,6 +10,7 @@ import { IObjectManagementService } from 'mssql';
import * as localizedConstants from '../localizedConstants'; import * as localizedConstants from '../localizedConstants';
import * as constants from '../constants'; import * as constants from '../constants';
import { Server, ServerViewInfo, NumaNode, AffinityType, ServerLoginMode, AuditLevel } from '../interfaces'; import { Server, ServerViewInfo, NumaNode, AffinityType, ServerLoginMode, AuditLevel } from '../interfaces';
import { isUndefinedOrNull } from '../../types';
const Dialog_Width = '750px'; const Dialog_Width = '750px';
@@ -157,6 +158,19 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
} }
private initializeGeneralSection(): void { private initializeGeneralSection(): void {
// Information about the platform that the SQL instance is running on
let platformItems: azdata.Component[] = [];
if (this.objectInfo.hardwareGeneration) {
this.hardwareGenerationInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.HardwareGenerationText,
inputType: 'text',
enabled: this.options.isNewObject,
value: this.objectInfo.hardwareGeneration.toString()
});
const hardwareGenerationContainer = this.createLabelInputContainer(localizedConstants.HardwareGenerationText, this.hardwareGenerationInput);
platformItems.push(hardwareGenerationContainer);
}
this.nameInput = this.createInputBox(async () => { }, { this.nameInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.NameText, ariaLabel: localizedConstants.NameText,
inputType: 'text', inputType: 'text',
@@ -164,17 +178,11 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.name value: this.objectInfo.name
}); });
const nameContainer = this.createLabelInputContainer(localizedConstants.NameText, this.nameInput); const nameContainer = this.createLabelInputContainer(localizedConstants.NameText, this.nameInput);
platformItems.push(nameContainer);
this.hardwareGenerationInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.HardwareGenerationText,
inputType: 'text',
enabled: this.options.isNewObject,
value: this.objectInfo.hardwareGeneration.toString()
});
const hardwareGenerationContainer = this.createLabelInputContainer(localizedConstants.HardwareGenerationText, this.hardwareGenerationInput);
this.languageDropdown = this.createDropdown(localizedConstants.LanguageText, async () => { }, [this.objectInfo.language], this.objectInfo.language, this.options.isNewObject); this.languageDropdown = this.createDropdown(localizedConstants.LanguageText, async () => { }, [this.objectInfo.language], this.objectInfo.language, this.options.isNewObject);
const languageContainer = this.createLabelInputContainer(localizedConstants.LanguageText, this.languageDropdown); const languageContainer = this.createLabelInputContainer(localizedConstants.LanguageText, this.languageDropdown);
platformItems.push(languageContainer);
this.memoryInput = this.createInputBox(async () => { }, { this.memoryInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.MemoryText, ariaLabel: localizedConstants.MemoryText,
@@ -183,6 +191,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: localizedConstants.StringValueInMB(this.objectInfo.memoryInMB.toString()) value: localizedConstants.StringValueInMB(this.objectInfo.memoryInMB.toString())
}); });
const memoryContainer = this.createLabelInputContainer(localizedConstants.MemoryText, this.memoryInput); const memoryContainer = this.createLabelInputContainer(localizedConstants.MemoryText, this.memoryInput);
platformItems.push(memoryContainer);
this.operatingSystemInput = this.createInputBox(async () => { }, { this.operatingSystemInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.OperatingSystemText, ariaLabel: localizedConstants.OperatingSystemText,
@@ -191,6 +200,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.operatingSystem value: this.objectInfo.operatingSystem
}); });
const operatingSystemContainer = this.createLabelInputContainer(localizedConstants.OperatingSystemText, this.operatingSystemInput); const operatingSystemContainer = this.createLabelInputContainer(localizedConstants.OperatingSystemText, this.operatingSystemInput);
platformItems.push(operatingSystemContainer);
this.platformInput = this.createInputBox(async () => { }, { this.platformInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.PlatformText, ariaLabel: localizedConstants.PlatformText,
@@ -199,6 +209,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.platform value: this.objectInfo.platform
}); });
const platformContainer = this.createLabelInputContainer(localizedConstants.PlatformText, this.platformInput); const platformContainer = this.createLabelInputContainer(localizedConstants.PlatformText, this.platformInput);
platformItems.push(platformContainer);
this.processorsInput = this.createInputBox(async () => { }, { this.processorsInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.ProcessorsText, ariaLabel: localizedConstants.ProcessorsText,
@@ -207,7 +218,10 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.processors value: this.objectInfo.processors
}); });
const processorsContainer = this.createLabelInputContainer(localizedConstants.ProcessorsText, this.processorsInput); const processorsContainer = this.createLabelInputContainer(localizedConstants.ProcessorsText, this.processorsInput);
platformItems.push(processorsContainer);
// Information about the SQL instance itself
let sqlServerItems: azdata.Component[] = [];
this.isClusteredInput = this.createInputBox(async () => { }, { this.isClusteredInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.IsClusteredText, ariaLabel: localizedConstants.IsClusteredText,
inputType: 'text', inputType: 'text',
@@ -215,6 +229,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.isClustered.toString() value: this.objectInfo.isClustered.toString()
}); });
const isClusteredContainer = this.createLabelInputContainer(localizedConstants.IsClusteredText, this.isClusteredInput); const isClusteredContainer = this.createLabelInputContainer(localizedConstants.IsClusteredText, this.isClusteredInput);
sqlServerItems.push(isClusteredContainer);
this.isHadrEnabledInput = this.createInputBox(async () => { }, { this.isHadrEnabledInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.IsHadrEnabledText, ariaLabel: localizedConstants.IsHadrEnabledText,
@@ -223,22 +238,29 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.isHadrEnabled.toString() value: this.objectInfo.isHadrEnabled.toString()
}); });
const isHadrEnabledContainer = this.createLabelInputContainer(localizedConstants.IsHadrEnabledText, this.isHadrEnabledInput); const isHadrEnabledContainer = this.createLabelInputContainer(localizedConstants.IsHadrEnabledText, this.isHadrEnabledInput);
sqlServerItems.push(isHadrEnabledContainer);
this.isPolyBaseInstalledInput = this.createInputBox(async () => { }, { if (!isUndefinedOrNull(this.objectInfo.isPolyBaseInstalled)) {
ariaLabel: localizedConstants.IsPolyBaseInstalledText, this.isPolyBaseInstalledInput = this.createInputBox(async () => { }, {
inputType: 'text', ariaLabel: localizedConstants.IsPolyBaseInstalledText,
enabled: this.options.isNewObject, inputType: 'text',
value: this.objectInfo.isPolyBaseInstalled.toString() enabled: this.options.isNewObject,
}); value: this.objectInfo.isPolyBaseInstalled.toString()
const isPolyBaseInstalledContainer = this.createLabelInputContainer(localizedConstants.IsPolyBaseInstalledText, this.isPolyBaseInstalledInput); });
const isPolyBaseInstalledContainer = this.createLabelInputContainer(localizedConstants.IsPolyBaseInstalledText, this.isPolyBaseInstalledInput);
sqlServerItems.push(isPolyBaseInstalledContainer);
}
this.isXTPSupportedInput = this.createInputBox(async () => { }, { if (!isUndefinedOrNull(this.objectInfo.isXTPSupported)) {
ariaLabel: localizedConstants.IsXTPSupportedText, this.isXTPSupportedInput = this.createInputBox(async () => { }, {
inputType: 'text', ariaLabel: localizedConstants.IsXTPSupportedText,
enabled: this.options.isNewObject, inputType: 'text',
value: this.objectInfo.isXTPSupported.toString() enabled: this.options.isNewObject,
}); value: this.objectInfo.isXTPSupported.toString()
const isXTPSupportedContainer = this.createLabelInputContainer(localizedConstants.IsXTPSupportedText, this.isXTPSupportedInput); });
const isXTPSupportedContainer = this.createLabelInputContainer(localizedConstants.IsXTPSupportedText, this.isXTPSupportedInput);
sqlServerItems.push(isXTPSupportedContainer);
}
this.productInput = this.createInputBox(async () => { }, { this.productInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.ProductText, ariaLabel: localizedConstants.ProductText,
@@ -247,14 +269,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.product value: this.objectInfo.product
}); });
const productContainer = this.createLabelInputContainer(localizedConstants.ProductText, this.productInput); const productContainer = this.createLabelInputContainer(localizedConstants.ProductText, this.productInput);
sqlServerItems.push(productContainer);
this.reservedStorageSizeInMBInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.ReservedStorageSizeInMBText,
inputType: 'text',
enabled: this.options.isNewObject,
value: localizedConstants.StringValueInMB(this.objectInfo.reservedStorageSizeMB.toString())
});
const reservedStorageSizeInMBContainer = this.createLabelInputContainer(localizedConstants.ReservedStorageSizeInMBText, this.reservedStorageSizeInMBInput);
this.rootDirectoryInput = this.createInputBox(async () => { }, { this.rootDirectoryInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.RootDirectoryText, ariaLabel: localizedConstants.RootDirectoryText,
@@ -263,6 +278,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.rootDirectory value: this.objectInfo.rootDirectory
}); });
const rootDirectoryContainer = this.createLabelInputContainer(localizedConstants.RootDirectoryText, this.rootDirectoryInput); const rootDirectoryContainer = this.createLabelInputContainer(localizedConstants.RootDirectoryText, this.rootDirectoryInput);
sqlServerItems.push(rootDirectoryContainer);
this.serverCollationInput = this.createInputBox(async () => { }, { this.serverCollationInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.ServerCollationText, ariaLabel: localizedConstants.ServerCollationText,
@@ -271,22 +287,7 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.serverCollation value: this.objectInfo.serverCollation
}); });
const serverCollationContainer = this.createLabelInputContainer(localizedConstants.ServerCollationText, this.serverCollationInput); const serverCollationContainer = this.createLabelInputContainer(localizedConstants.ServerCollationText, this.serverCollationInput);
sqlServerItems.push(serverCollationContainer);
this.serviceTierInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.ServiceTierText,
inputType: 'text',
enabled: this.options.isNewObject,
value: this.objectInfo.serviceTier
});
const serviceTierContainer = this.createLabelInputContainer(localizedConstants.ServiceTierText, this.serviceTierInput);
this.storageSpaceUsageInMBInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.StorageSpaceUsageInMBText,
inputType: 'text',
enabled: this.options.isNewObject,
value: localizedConstants.StringValueInMB(this.objectInfo.storageSpaceUsageInMB.toString())
});
const storageSpaceUsageInMbContainer = this.createLabelInputContainer(localizedConstants.StorageSpaceUsageInMBText, this.storageSpaceUsageInMBInput);
this.versionInput = this.createInputBox(async () => { }, { this.versionInput = this.createInputBox(async () => { }, {
ariaLabel: localizedConstants.VersionText, ariaLabel: localizedConstants.VersionText,
@@ -295,32 +296,39 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
value: this.objectInfo.version value: this.objectInfo.version
}); });
const versionContainer = this.createLabelInputContainer(localizedConstants.VersionText, this.versionInput); const versionContainer = this.createLabelInputContainer(localizedConstants.VersionText, this.versionInput);
sqlServerItems.push(versionContainer);
let platformItems = [ if (!isUndefinedOrNull(this.objectInfo.reservedStorageSizeMB)) {
nameContainer, this.reservedStorageSizeInMBInput = this.createInputBox(async () => { }, {
languageContainer, ariaLabel: localizedConstants.ReservedStorageSizeInMBText,
memoryContainer, inputType: 'text',
operatingSystemContainer, enabled: this.options.isNewObject,
platformContainer, value: localizedConstants.StringValueInMB(this.objectInfo.reservedStorageSizeMB.toString())
processorsContainer });
]; const reservedStorageSizeInMBContainer = this.createLabelInputContainer(localizedConstants.ReservedStorageSizeInMBText, this.reservedStorageSizeInMBInput);
sqlServerItems.push(reservedStorageSizeInMBContainer);
}
let sqlServerItems = [ if (this.objectInfo.serviceTier) {
isClusteredContainer, this.serviceTierInput = this.createInputBox(async () => { }, {
isHadrEnabledContainer, ariaLabel: localizedConstants.ServiceTierText,
isPolyBaseInstalledContainer, inputType: 'text',
isXTPSupportedContainer, enabled: this.options.isNewObject,
productContainer, value: this.objectInfo.serviceTier
rootDirectoryContainer, });
serverCollationContainer, const serviceTierContainer = this.createLabelInputContainer(localizedConstants.ServiceTierText, this.serviceTierInput);
versionContainer sqlServerItems.push(serviceTierContainer);
]; }
if (this.engineEdition === azdata.DatabaseEngineEdition.SqlManagedInstance) { if (!isUndefinedOrNull(this.objectInfo.storageSpaceUsageInMB)) {
platformItems.unshift(hardwareGenerationContainer); this.storageSpaceUsageInMBInput = this.createInputBox(async () => { }, {
sqlServerItems.push(reservedStorageSizeInMBContainer, serviceTierContainer, storageSpaceUsageInMbContainer); ariaLabel: localizedConstants.StorageSpaceUsageInMBText,
// remove isXTPSupported inputType: 'text',
sqlServerItems.splice(3, 1); enabled: this.options.isNewObject,
value: localizedConstants.StringValueInMB(this.objectInfo.storageSpaceUsageInMB.toString())
});
const storageSpaceUsageInMbContainer = this.createLabelInputContainer(localizedConstants.StorageSpaceUsageInMBText, this.storageSpaceUsageInMBInput);
sqlServerItems.push(storageSpaceUsageInMbContainer);
} }
this.platformSection = this.createGroup('Platform', platformItems, true); this.platformSection = this.createGroup('Platform', platformItems, true);

View File

@@ -838,3 +838,9 @@ export async function ensureFileExists(absoluteFilePath: string, contents?: stri
} }
} }
} }
export function throwIfFailed(result: azdataType.ResultStatus | vscodeMssql.ResultStatus): void {
if (!result.success) {
throw new Error(constants.errorPrefix(result.errorMessage));
}
}

View File

@@ -183,7 +183,9 @@ export class ProjectsController {
throw new Error(constants.invalidTargetPlatform(creationParams.targetPlatform, Array.from(constants.targetPlatformToVersion.keys()))); throw new Error(constants.invalidTargetPlatform(creationParams.targetPlatform, Array.from(constants.targetPlatformToVersion.keys())));
} }
const targetPlatform = creationParams.targetPlatform ? constants.targetPlatformToVersion.get(creationParams.targetPlatform)! : constants.defaultDSP; let targetPlatform = creationParams.targetPlatform ? constants.targetPlatformToVersion.get(creationParams.targetPlatform)! : constants.defaultDSP;
targetPlatform = constants.MicrosoftDatatoolsSchemaSqlSql + targetPlatform + constants.databaseSchemaProvider;
let newProjFileName = creationParams.newProjName; let newProjFileName = creationParams.newProjName;
@@ -197,15 +199,19 @@ export class ProjectsController {
throw new Error(constants.projectAlreadyExists(newProjFileName, path.parse(newProjFilePath).dir)); throw new Error(constants.projectAlreadyExists(newProjFileName, path.parse(newProjFilePath).dir));
} }
let result: azdataType.ResultStatus | mssqlVscode.ResultStatus;
const sqlProjectsService = await utils.getSqlProjectsService(); const sqlProjectsService = await utils.getSqlProjectsService();
if (utils.getAzdataApi()) { if (utils.getAzdataApi()) {
const projectStyle = creationParams.sdkStyle ? mssql.ProjectType.SdkStyle : mssql.ProjectType.LegacyStyle; const projectStyle = creationParams.sdkStyle ? mssql.ProjectType.SdkStyle : mssql.ProjectType.LegacyStyle;
await (sqlProjectsService as mssql.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform); result = await (sqlProjectsService as mssql.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
} else { } else {
const projectStyle = creationParams.sdkStyle ? mssqlVscode.ProjectType.SdkStyle : mssqlVscode.ProjectType.LegacyStyle; const projectStyle = creationParams.sdkStyle ? mssqlVscode.ProjectType.SdkStyle : mssqlVscode.ProjectType.LegacyStyle;
await (sqlProjectsService as mssqlVscode.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform); result = await (sqlProjectsService as mssqlVscode.ISqlProjectsService).createProject(newProjFilePath, projectStyle, targetPlatform);
} }
utils.throwIfFailed(result);
await this.addTemplateFiles(newProjFilePath, creationParams.projectTypeId); await this.addTemplateFiles(newProjFilePath, creationParams.projectTypeId);
return newProjFilePath; return newProjFilePath;

View File

@@ -248,7 +248,7 @@ export class Project implements ISqlProject {
} }
const result = await sqlProjService.getProjectProperties(this.projectFilePath); const result = await sqlProjService.getProjectProperties(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
this._projectGuid = result.projectGuid; this._projectGuid = result.projectGuid;
@@ -274,7 +274,7 @@ export class Project implements ISqlProject {
private async readCrossPlatformCompatibility(): Promise<void> { private async readCrossPlatformCompatibility(): Promise<void> {
const result = await this.sqlProjService.getCrossPlatformCompatibility(this.projectFilePath) const result = await this.sqlProjService.getCrossPlatformCompatibility(this.projectFilePath)
this.throwIfFailed(result); utils.throwIfFailed(result);
this._isCrossPlatformCompatible = result.isCrossPlatformCompatible; this._isCrossPlatformCompatible = result.isCrossPlatformCompatible;
} }
@@ -302,7 +302,7 @@ export class Project implements ISqlProject {
var result: GetScriptsResult = await this.sqlProjService.getSqlObjectScripts(this.projectFilePath); var result: GetScriptsResult = await this.sqlProjService.getSqlObjectScripts(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
if (result.scripts?.length > 0) { // empty array from SqlToolsService is deserialized as null if (result.scripts?.length > 0) { // empty array from SqlToolsService is deserialized as null
for (var script of result.scripts) { for (var script of result.scripts) {
@@ -326,7 +326,7 @@ export class Project implements ISqlProject {
private async readFolders(): Promise<void> { private async readFolders(): Promise<void> {
var result: GetFoldersResult = await this.sqlProjService.getFolders(this.projectFilePath); var result: GetFoldersResult = await this.sqlProjService.getFolders(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
const folderEntries: FileProjectEntry[] = []; const folderEntries: FileProjectEntry[] = [];
@@ -349,7 +349,7 @@ export class Project implements ISqlProject {
private async readPreDeployScripts(warnIfMultiple: boolean = false): Promise<void> { private async readPreDeployScripts(warnIfMultiple: boolean = false): Promise<void> {
var result: GetScriptsResult = await this.sqlProjService.getPreDeploymentScripts(this.projectFilePath); var result: GetScriptsResult = await this.sqlProjService.getPreDeploymentScripts(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
const preDeploymentScriptEntries: FileProjectEntry[] = []; const preDeploymentScriptEntries: FileProjectEntry[] = [];
@@ -368,7 +368,7 @@ export class Project implements ISqlProject {
private async readPostDeployScripts(warnIfMultiple: boolean = false): Promise<void> { private async readPostDeployScripts(warnIfMultiple: boolean = false): Promise<void> {
var result: GetScriptsResult = await this.sqlProjService.getPostDeploymentScripts(this.projectFilePath); var result: GetScriptsResult = await this.sqlProjService.getPostDeploymentScripts(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
const postDeploymentScriptEntries: FileProjectEntry[] = []; const postDeploymentScriptEntries: FileProjectEntry[] = [];
@@ -394,7 +394,7 @@ export class Project implements ISqlProject {
} }
var result: GetScriptsResult = await sqlProjService.getNoneItems(this.projectFilePath); var result: GetScriptsResult = await sqlProjService.getNoneItems(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
const noneItemEntries: FileProjectEntry[] = []; const noneItemEntries: FileProjectEntry[] = [];
@@ -510,7 +510,7 @@ export class Project implements ISqlProject {
} }
const result = await this.sqlProjService.updateProjectForCrossPlatform(this.projectFilePath); const result = await this.sqlProjService.updateProjectForCrossPlatform(this.projectFilePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readCrossPlatformCompatibility(); await this.readCrossPlatformCompatibility();
} }
@@ -529,7 +529,7 @@ export class Project implements ISqlProject {
} }
const result = await this.sqlProjService.addFolder(this.projectFilePath, relativeFolderPath); const result = await this.sqlProjService.addFolder(this.projectFilePath, relativeFolderPath);
this.throwIfFailed(result); utils.throwIfFailed(result);
// Note: adding a folder does not mean adding the contents of the folder. // Note: adding a folder does not mean adding the contents of the folder.
// SDK projects may still need to adjust their include/exclude globs, and Legacy projects must still include each file // SDK projects may still need to adjust their include/exclude globs, and Legacy projects must still include each file
@@ -539,7 +539,7 @@ export class Project implements ISqlProject {
public async deleteFolder(relativeFolderPath: string): Promise<void> { public async deleteFolder(relativeFolderPath: string): Promise<void> {
const result = await this.sqlProjService.deleteFolder(this.projectFilePath, relativeFolderPath); const result = await this.sqlProjService.deleteFolder(this.projectFilePath, relativeFolderPath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
await this.readPreDeployScripts(); await this.readPreDeployScripts();
@@ -550,7 +550,7 @@ export class Project implements ISqlProject {
public async excludeFolder(relativeFolderPath: string): Promise<void> { public async excludeFolder(relativeFolderPath: string): Promise<void> {
const result = await this.sqlProjService.excludeFolder(this.projectFilePath, relativeFolderPath); const result = await this.sqlProjService.excludeFolder(this.projectFilePath, relativeFolderPath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
await this.readPreDeployScripts(); await this.readPreDeployScripts();
@@ -561,7 +561,7 @@ export class Project implements ISqlProject {
public async moveFolder(relativeSourcePath: string, relativeDestinationPath: string): Promise<void> { public async moveFolder(relativeSourcePath: string, relativeDestinationPath: string): Promise<void> {
const result = await this.sqlProjService.moveFolder(this.projectFilePath, relativeSourcePath, relativeDestinationPath); const result = await this.sqlProjService.moveFolder(this.projectFilePath, relativeSourcePath, relativeDestinationPath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
await this.readPreDeployScripts(); await this.readPreDeployScripts();
@@ -576,7 +576,7 @@ export class Project implements ISqlProject {
public async addSqlObjectScript(relativePath: string, reloadAfter: boolean = true): Promise<void> { public async addSqlObjectScript(relativePath: string, reloadAfter: boolean = true): Promise<void> {
const result = await this.sqlProjService.addSqlObjectScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.addSqlObjectScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
if (reloadAfter) { if (reloadAfter) {
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
@@ -595,7 +595,7 @@ export class Project implements ISqlProject {
public async deleteSqlObjectScript(relativePath: string): Promise<void> { public async deleteSqlObjectScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.deleteSqlObjectScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.deleteSqlObjectScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
await this.readFolders(); await this.readFolders();
@@ -603,7 +603,7 @@ export class Project implements ISqlProject {
public async excludeSqlObjectScript(relativePath: string): Promise<void> { public async excludeSqlObjectScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.excludeSqlObjectScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.excludeSqlObjectScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlObjectScripts(); await this.readSqlObjectScripts();
await this.readFolders(); await this.readFolders();
@@ -619,7 +619,7 @@ export class Project implements ISqlProject {
} }
const result = await this.sqlProjService.addPreDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.addPreDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPreDeployScripts(); await this.readPreDeployScripts();
await this.readNoneItems(); await this.readNoneItems();
@@ -628,7 +628,7 @@ export class Project implements ISqlProject {
public async deletePreDeploymentScript(relativePath: string): Promise<void> { public async deletePreDeploymentScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.deletePreDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.deletePreDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPreDeployScripts(); await this.readPreDeployScripts();
await this.readFolders(); await this.readFolders();
@@ -636,7 +636,7 @@ export class Project implements ISqlProject {
public async excludePreDeploymentScript(relativePath: string): Promise<void> { public async excludePreDeploymentScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.excludePreDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.excludePreDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPreDeployScripts(); await this.readPreDeployScripts();
await this.readFolders(); await this.readFolders();
@@ -652,7 +652,7 @@ export class Project implements ISqlProject {
} }
const result = await this.sqlProjService.addPostDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.addPostDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPostDeployScripts(); await this.readPostDeployScripts();
await this.readNoneItems(); await this.readNoneItems();
@@ -661,7 +661,7 @@ export class Project implements ISqlProject {
public async deletePostDeploymentScript(relativePath: string): Promise<void> { public async deletePostDeploymentScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.deletePostDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.deletePostDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPostDeployScripts(); await this.readPostDeployScripts();
await this.readFolders(); await this.readFolders();
@@ -669,7 +669,7 @@ export class Project implements ISqlProject {
public async excludePostDeploymentScript(relativePath: string): Promise<void> { public async excludePostDeploymentScript(relativePath: string): Promise<void> {
const result = await this.sqlProjService.excludePostDeploymentScript(this.projectFilePath, relativePath); const result = await this.sqlProjService.excludePostDeploymentScript(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readPostDeployScripts(); await this.readPostDeployScripts();
await this.readFolders(); await this.readFolders();
@@ -681,7 +681,7 @@ export class Project implements ISqlProject {
public async addNoneItem(relativePath: string): Promise<void> { public async addNoneItem(relativePath: string): Promise<void> {
const result = await this.sqlProjService.addNoneItem(this.projectFilePath, relativePath); const result = await this.sqlProjService.addNoneItem(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readNoneItems(); await this.readNoneItems();
await this.readFolders(); await this.readFolders();
@@ -689,7 +689,7 @@ export class Project implements ISqlProject {
public async deleteNoneItem(relativePath: string): Promise<void> { public async deleteNoneItem(relativePath: string): Promise<void> {
const result = await this.sqlProjService.deleteNoneItem(this.projectFilePath, relativePath); const result = await this.sqlProjService.deleteNoneItem(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readNoneItems(); await this.readNoneItems();
await this.readFolders(); await this.readFolders();
@@ -697,7 +697,7 @@ export class Project implements ISqlProject {
public async excludeNoneItem(relativePath: string): Promise<void> { public async excludeNoneItem(relativePath: string): Promise<void> {
const result = await this.sqlProjService.excludeNoneItem(this.projectFilePath, relativePath); const result = await this.sqlProjService.excludeNoneItem(this.projectFilePath, relativePath);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readNoneItems(); await this.readNoneItems();
await this.readFolders(); await this.readFolders();
@@ -764,7 +764,7 @@ export class Project implements ISqlProject {
await this.readNoneItems(); await this.readNoneItems();
} }
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readFolders(); await this.readFolders();
return this.createFileProjectEntry(normalizedRelativeFilePath, EntryType.File); return this.createFileProjectEntry(normalizedRelativeFilePath, EntryType.File);
@@ -788,7 +788,7 @@ export class Project implements ISqlProject {
this._databaseSchemaProvider = `${constants.MicrosoftDatatoolsSchemaSqlSql}${compatLevel}${constants.databaseSchemaProvider}`; this._databaseSchemaProvider = `${constants.MicrosoftDatatoolsSchemaSqlSql}${compatLevel}${constants.databaseSchemaProvider}`;
const result = await this.sqlProjService.setDatabaseSchemaProvider(this.projectFilePath, this._databaseSchemaProvider); const result = await this.sqlProjService.setDatabaseSchemaProvider(this.projectFilePath, this._databaseSchemaProvider);
this.throwIfFailed(result); utils.throwIfFailed(result);
} }
/** /**
@@ -921,7 +921,7 @@ export class Project implements ISqlProject {
public async deleteDatabaseReference(name: string): Promise<void> { public async deleteDatabaseReference(name: string): Promise<void> {
const result = await this.sqlProjService.deleteDatabaseReference(this.projectFilePath, name); const result = await this.sqlProjService.deleteDatabaseReference(this.projectFilePath, name);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readDatabaseReferences(); await this.readDatabaseReferences();
} }
@@ -936,7 +936,7 @@ export class Project implements ISqlProject {
*/ */
public async addSqlCmdVariable(name: string, defaultValue: string): Promise<void> { public async addSqlCmdVariable(name: string, defaultValue: string): Promise<void> {
const result = await this.sqlProjService.addSqlCmdVariable(this.projectFilePath, name, defaultValue); const result = await this.sqlProjService.addSqlCmdVariable(this.projectFilePath, name, defaultValue);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlCmdVariables(); await this.readSqlCmdVariables();
} }
@@ -947,13 +947,13 @@ export class Project implements ISqlProject {
*/ */
public async updateSqlCmdVariable(name: string, defaultValue: string): Promise<void> { public async updateSqlCmdVariable(name: string, defaultValue: string): Promise<void> {
const result = await this.sqlProjService.updateSqlCmdVariable(this.projectFilePath, name, defaultValue); const result = await this.sqlProjService.updateSqlCmdVariable(this.projectFilePath, name, defaultValue);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlCmdVariables(); await this.readSqlCmdVariables();
} }
public async deleteSqlCmdVariable(variableName: string): Promise<void> { public async deleteSqlCmdVariable(variableName: string): Promise<void> {
const result = await this.sqlProjService.deleteSqlCmdVariable(this.projectFilePath, variableName); const result = await this.sqlProjService.deleteSqlCmdVariable(this.projectFilePath, variableName);
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readSqlCmdVariables(); await this.readSqlCmdVariables();
} }
@@ -979,7 +979,7 @@ export class Project implements ISqlProject {
sources.push(databaseSource); sources.push(databaseSource);
const result = await this.sqlProjService.setDatabaseSource(this.projectFilePath, sources.join(';')); const result = await this.sqlProjService.setDatabaseSource(this.projectFilePath, sources.join(';'));
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readProjectProperties(); await this.readProjectProperties();
} }
@@ -1005,7 +1005,7 @@ export class Project implements ISqlProject {
sources.splice(index, 1); sources.splice(index, 1);
const result = await this.sqlProjService.setDatabaseSource(this.projectFilePath, sources.join(';')); const result = await this.sqlProjService.setDatabaseSource(this.projectFilePath, sources.join(';'));
this.throwIfFailed(result); utils.throwIfFailed(result);
await this.readProjectProperties(); await this.readProjectProperties();
} }
@@ -1029,12 +1029,6 @@ export class Project implements ISqlProject {
containsCreateTableStatement); containsCreateTableStatement);
} }
private throwIfFailed(result: ResultStatus): void {
if (!result.success) {
throw new Error(constants.errorPrefix(result.errorMessage));
}
}
/** /**
* Moves a file to a different location * Moves a file to a different location
* @param node Node being moved * @param node Node being moved

View File

@@ -1016,7 +1016,7 @@ describe('Project: properties', function (): void {
throw new Error('Should not have succeeded.'); throw new Error('Should not have succeeded.');
} catch (e) { } catch (e) {
(e.message).should.startWith('Error: Invalid value for Database Schema Provider:'); (e.message).should.startWith('Error: Invalid value for Database Schema Provider:');
(e.message).should.endWith('expected to be in the form Microsoft.Data.Tools.Schema.Sql.Sql160DatabaseSchemaProvider'); (e.message).should.endWith('expected to be in the form \'Microsoft.Data.Tools.Schema.Sql.Sql160DatabaseSchemaProvider\'.');
} }
}); });