mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 09:35:37 -05:00
More add database reference dialog UI (#12066)
* add suppress missing dependencies checkbox * add example usage * set font-styles * Fix typo * allow example usage to be selectable * don't localize example usage * move example usage strings to a new section
This commit is contained in:
@@ -110,6 +110,11 @@ export const databaseName = localize('databaseName', "Database name");
|
||||
export const databaseVariable = localize('databaseVariable', "Database variable");
|
||||
export const serverName = localize('serverName', "Server name");
|
||||
export const serverVariable = localize('serverVariable', "Server variable");
|
||||
export const suppressMissingDependenciesErrors = localize('suppressMissingDependenciesErrors', "Suppress errors caused by unresolved references in the referenced project");
|
||||
export const exampleUsage = localize('exampleUsage', "Example Usage");
|
||||
export const enterSystemDbName = localize('enterSystemDbName', "Enter a database name for this system database");
|
||||
export const databaseNameRequiredVariableOptional = localize('databaseNameRequiredVariableOptional', "A database name is required. The database variable is optional.");
|
||||
export const databaseNameServerNameVariableRequired = localize('databaseNameServerNameVariableRequired', "A database name, server name, and server variable are required. The database variable is optional");
|
||||
|
||||
// Error messages
|
||||
|
||||
@@ -207,6 +212,8 @@ export const TargetConnectionString = 'TargetConnectionString';
|
||||
export const PreDeploy = 'PreDeploy';
|
||||
export const PostDeploy = 'PostDeploy';
|
||||
export const None = 'None';
|
||||
export const True = 'True';
|
||||
export const False = 'False';
|
||||
|
||||
// SqlProj File targets
|
||||
export const NetCoreTargets = '$(NETCoreTargetsPath)\\Microsoft.Data.Tools.Schema.SqlTasks.targets';
|
||||
@@ -262,3 +269,8 @@ export enum DatabaseProjectItemType {
|
||||
|
||||
// System dbs
|
||||
export const systemDbs = ['master', 'msdb', 'tempdb', 'model'];
|
||||
|
||||
// SQL queries
|
||||
export const sameDatabaseExampleUsage = 'SELECT * FROM [Schema1].[Table1]';
|
||||
export function differentDbSameServerExampleUsage(db: string) { return `SELECT * FROM [${db}].[Schema1].[Table1]"`; }
|
||||
export function differentDbDifferentServerExampleUsage(server: string, db: string) { return `SELECT * FROM [${server}].[${db}].[Schema1].[Table1]`; }
|
||||
|
||||
@@ -15,4 +15,10 @@ export namespace cssStyles {
|
||||
|
||||
export const addDatabaseReferenceDialogLabelWidth = '215px';
|
||||
export const addDatabaseReferenceInputboxWidth = '220px';
|
||||
|
||||
// font-styles
|
||||
export namespace fontStyle {
|
||||
export const normal = 'normal';
|
||||
export const italics = 'italic';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ export class AddDatabaseReferenceDialog {
|
||||
public databaseVariableTextbox: azdata.InputBoxComponent | undefined;
|
||||
public serverNameTextbox: azdata.InputBoxComponent | undefined;
|
||||
public serverVariableTextbox: azdata.InputBoxComponent | undefined;
|
||||
public suppressMissingDependenciesErrorsCheckbox: azdata.CheckBoxComponent | undefined;
|
||||
public exampleUsage: azdata.TextComponent | undefined;
|
||||
|
||||
public currentReferenceType: ReferenceType | undefined;
|
||||
private referenceLocationMap: Map<string, DatabaseReferenceLocation>;
|
||||
@@ -87,6 +89,10 @@ export class AddDatabaseReferenceDialog {
|
||||
this.dacpacFormComponent = this.createDacpacTextbox();
|
||||
const locationDropdown = this.createLocationDropdown();
|
||||
const variableSection = this.createVariableSection();
|
||||
this.suppressMissingDependenciesErrorsCheckbox = view.modelBuilder.checkBox().withProperties({
|
||||
label: constants.suppressMissingDependenciesErrors
|
||||
}).component();
|
||||
const exampleUsage = this.createExampleUsage();
|
||||
|
||||
this.formBuilder = <azdata.FormBuilder>view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
@@ -96,7 +102,11 @@ export class AddDatabaseReferenceDialog {
|
||||
radioButtonGroup,
|
||||
this.systemDatabaseFormComponent,
|
||||
locationDropdown,
|
||||
variableSection
|
||||
variableSection,
|
||||
exampleUsage,
|
||||
{
|
||||
component: this.suppressMissingDependenciesErrorsCheckbox
|
||||
}
|
||||
]
|
||||
}
|
||||
], {
|
||||
@@ -119,7 +129,8 @@ export class AddDatabaseReferenceDialog {
|
||||
if (this.currentReferenceType === ReferenceType.systemDb) {
|
||||
referenceSettings = {
|
||||
databaseName: <string>this.databaseNameTextbox?.value,
|
||||
systemDb: <string>this.systemDatabaseDropdown?.value === constants.master ? SystemDatabase.master : SystemDatabase.msdb
|
||||
systemDb: <string>this.systemDatabaseDropdown?.value === constants.master ? SystemDatabase.master : SystemDatabase.msdb,
|
||||
suppressMissingDependenciesErrors: <boolean>this.suppressMissingDependenciesErrorsCheckbox?.checked
|
||||
};
|
||||
} else { // this.currentReferenceType === ReferenceType.dacpac
|
||||
referenceSettings = {
|
||||
@@ -128,7 +139,8 @@ export class AddDatabaseReferenceDialog {
|
||||
dacpacFileLocation: vscode.Uri.file(<string>this.dacpacTextbox?.value),
|
||||
databaseVariable: <string>this.databaseVariableTextbox?.value,
|
||||
serverName: <string>this.serverNameTextbox?.value,
|
||||
serverVariable: <string>this.serverVariableTextbox?.value
|
||||
serverVariable: <string>this.serverVariableTextbox?.value,
|
||||
suppressMissingDependenciesErrors: <boolean>this.suppressMissingDependenciesErrorsCheckbox?.checked
|
||||
};
|
||||
// TODO: add project reference support
|
||||
}
|
||||
@@ -184,6 +196,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.currentReferenceType = ReferenceType.systemDb;
|
||||
this.updateEnabledInputBoxes(true);
|
||||
this.tryEnableAddReferenceButton();
|
||||
this.updateExampleUsage();
|
||||
}
|
||||
|
||||
public dacpacRadioButtonClick(): void {
|
||||
@@ -196,6 +209,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.currentReferenceType = ReferenceType.dacpac;
|
||||
this.updateEnabledInputBoxes();
|
||||
this.tryEnableAddReferenceButton();
|
||||
this.updateExampleUsage();
|
||||
}
|
||||
|
||||
private createSystemDatabaseDropdown(): azdata.FormComponent {
|
||||
@@ -219,11 +233,12 @@ export class AddDatabaseReferenceDialog {
|
||||
this.dacpacTextbox = this.view!.modelBuilder.inputBox().withProperties({
|
||||
ariaLabel: constants.dacpacText,
|
||||
placeHolder: constants.dacpacPlaceholder,
|
||||
width: '405px'
|
||||
width: '400px'
|
||||
}).component();
|
||||
|
||||
this.dacpacTextbox.onTextChanged(() => {
|
||||
this.tryEnableAddReferenceButton();
|
||||
this.updateExampleUsage();
|
||||
});
|
||||
|
||||
const loadDacpacButton = this.createLoadDacpacButton();
|
||||
@@ -239,9 +254,9 @@ export class AddDatabaseReferenceDialog {
|
||||
private createLoadDacpacButton(): azdata.ButtonComponent {
|
||||
const loadDacpacButton = this.view!.modelBuilder.button().withProperties({
|
||||
ariaLabel: constants.loadDacpacButton,
|
||||
iconPath: IconPathHelper.folder,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
height: '16px',
|
||||
width: '15px'
|
||||
width: '16px'
|
||||
}).component();
|
||||
|
||||
loadDacpacButton.onDidClick(async () => {
|
||||
@@ -277,6 +292,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.locationDropdown.onValueChanged(() => {
|
||||
this.updateEnabledInputBoxes();
|
||||
this.tryEnableAddReferenceButton();
|
||||
this.updateExampleUsage();
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -336,7 +352,7 @@ export class AddDatabaseReferenceDialog {
|
||||
this.serverVariableTextbox = this.createInputBox(constants.serverVariable, false);
|
||||
const serverVariableRow = this.view!.modelBuilder.flexContainer().withItems([this.createLabel(constants.serverVariable, true), this.serverVariableTextbox], { flex: '0 0 auto' }).withLayout({ flexFlow: 'row', alignItems: 'center' }).component();
|
||||
|
||||
const variableSection = this.view!.modelBuilder.flexContainer().withItems([databaseNameRow, databaseVariableRow, serverNameRow, serverVariableRow]).withLayout({ flexFlow: 'column' }).component();
|
||||
const variableSection = this.view!.modelBuilder.flexContainer().withItems([databaseNameRow, databaseVariableRow, serverNameRow, serverVariableRow]).withLayout({ flexFlow: 'column' }).withProperties({ CSSStyles: { 'margin-bottom': '25px' } }).component();
|
||||
|
||||
return {
|
||||
component: variableSection,
|
||||
@@ -363,11 +379,62 @@ export class AddDatabaseReferenceDialog {
|
||||
|
||||
inputBox.onTextChanged(() => {
|
||||
this.tryEnableAddReferenceButton();
|
||||
this.updateExampleUsage();
|
||||
});
|
||||
|
||||
return inputBox;
|
||||
}
|
||||
|
||||
private createExampleUsage(): azdata.FormComponent {
|
||||
this.exampleUsage = this.view!.modelBuilder.text().withProperties({
|
||||
value: constants.systemDatabaseReferenceRequired,
|
||||
CSSStyles: { 'user-select': 'text' }
|
||||
}).component();
|
||||
|
||||
const exampleUsageWrapper = this.view!.modelBuilder.flexContainer().withItems([this.exampleUsage], { CSSStyles: { 'width': '415px', 'height': '80px', 'padding': '0 10px', 'border': '1px solid #8a8886', 'font-style': 'italic' } }).component();
|
||||
|
||||
return {
|
||||
component: exampleUsageWrapper,
|
||||
title: constants.exampleUsage
|
||||
};
|
||||
}
|
||||
|
||||
private updateExampleUsage(): void {
|
||||
let newText = '';
|
||||
let fontStyle = cssStyles.fontStyle.normal; // font-style should be normal for example usage and italics if showing message that a required field needs to be filled
|
||||
|
||||
switch (this.locationDropdown!.value) {
|
||||
case constants.sameDatabase: {
|
||||
newText = constants.sameDatabaseExampleUsage;
|
||||
break;
|
||||
}
|
||||
case constants.differentDbSameServer: {
|
||||
if (!this.databaseNameTextbox?.value) {
|
||||
newText = this.currentReferenceType === ReferenceType.systemDb ? constants.enterSystemDbName : constants.databaseNameRequiredVariableOptional;
|
||||
fontStyle = cssStyles.fontStyle.italics;
|
||||
} else {
|
||||
const db = this.databaseVariableTextbox?.value ? this.databaseVariableTextbox?.value : this.databaseNameTextbox.value;
|
||||
newText = constants.differentDbSameServerExampleUsage(db);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constants.differentDbDifferentServer: {
|
||||
if (!this.databaseNameTextbox?.value || !this.serverNameTextbox?.value || !this.serverVariableTextbox?.value) {
|
||||
newText = constants.databaseNameServerNameVariableRequired;
|
||||
fontStyle = cssStyles.fontStyle.italics;
|
||||
} else {
|
||||
const server = this.serverVariableTextbox.value;
|
||||
const db = this.databaseVariableTextbox?.value ? this.databaseVariableTextbox?.value : this.databaseNameTextbox.value;
|
||||
newText = constants.differentDbDifferentServerExampleUsage(server, db);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.exampleUsage!.value = newText;
|
||||
this.exampleUsage?.updateCssStyles({ 'font-style': fontStyle });
|
||||
}
|
||||
|
||||
/**
|
||||
* Only enable Add reference button if all enabled fields are filled
|
||||
*/
|
||||
|
||||
@@ -509,7 +509,7 @@ export class PublishDatabaseDialog {
|
||||
ariaLabel: constants.loadProfilePlaceholderText,
|
||||
iconPath: IconPathHelper.folder_blue,
|
||||
height: '16px',
|
||||
width: '15px'
|
||||
width: '16px'
|
||||
}).component();
|
||||
|
||||
loadProfileButton.onDidClick(async () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Uri } from 'vscode';
|
||||
|
||||
export interface IDatabaseReferenceSettings {
|
||||
databaseName?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
}
|
||||
|
||||
export interface ISystemDatabaseReferenceSettings extends IDatabaseReferenceSettings {
|
||||
|
||||
@@ -127,10 +127,14 @@ export class Project {
|
||||
const nameNodes = references[r].getElementsByTagName(constants.DatabaseVariableLiteralValue);
|
||||
const name = nameNodes.length === 1 ? nameNodes[0].childNodes[0].nodeValue : undefined;
|
||||
|
||||
const suppressMissingDependenciesErrorNode = references[r].getElementsByTagName(constants.SuppressMissingDependenciesErrors);
|
||||
const suppressMissingDependences = suppressMissingDependenciesErrorNode[0].childNodes[0].nodeValue === true ?? false;
|
||||
|
||||
this.databaseReferences.push(new DacpacReferenceProjectEntry({
|
||||
dacpacFileLocation: Uri.file(utils.getPlatformSafeFileEntryPath(filepath)),
|
||||
databaseLocation: name ? DatabaseReferenceLocation.differentDatabaseSameServer : DatabaseReferenceLocation.sameDatabase,
|
||||
databaseName: name
|
||||
databaseName: name,
|
||||
suppressMissingDependenciesErrors: suppressMissingDependences
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -145,7 +149,11 @@ export class Project {
|
||||
|
||||
const nameNodes = projectReferences[r].getElementsByTagName(constants.Name);
|
||||
const name = nameNodes[0].childNodes[0].nodeValue;
|
||||
this.databaseReferences.push(new SqlProjectReferenceProjectEntry(Uri.file(utils.getPlatformSafeFileEntryPath(filepath)), name));
|
||||
|
||||
const suppressMissingDependenciesErrorNode = projectReferences[r].getElementsByTagName(constants.SuppressMissingDependenciesErrors);
|
||||
const suppressMissingDependences = suppressMissingDependenciesErrorNode[0].childNodes[0].nodeValue === true ?? false;
|
||||
|
||||
this.databaseReferences.push(new SqlProjectReferenceProjectEntry(Uri.file(utils.getPlatformSafeFileEntryPath(filepath)), name, suppressMissingDependences));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +324,7 @@ export class Project {
|
||||
ssdtUri = this.getSystemDacpacSsdtUri(constants.msdbDacpac);
|
||||
}
|
||||
|
||||
const systemDatabaseReferenceProjectEntry = new SystemDatabaseReferenceProjectEntry(uri, ssdtUri, <string>settings.databaseName);
|
||||
const systemDatabaseReferenceProjectEntry = new SystemDatabaseReferenceProjectEntry(uri, ssdtUri, <string>settings.databaseName, settings.suppressMissingDependenciesErrors);
|
||||
await this.addToProjFile(systemDatabaseReferenceProjectEntry);
|
||||
}
|
||||
|
||||
@@ -512,10 +520,9 @@ export class Project {
|
||||
}
|
||||
|
||||
private addDatabaseReferenceChildren(referenceNode: any, entry: IDatabaseReferenceProjectEntry): void {
|
||||
// TODO: create checkbox for this setting
|
||||
const suppressMissingDependenciesErrorNode = this.projFileXmlDoc.createElement(constants.SuppressMissingDependenciesErrors);
|
||||
const falseTextNode = this.projFileXmlDoc.createTextNode('False');
|
||||
suppressMissingDependenciesErrorNode.appendChild(falseTextNode);
|
||||
const suppressMissingDependenciesErrorTextNode = this.projFileXmlDoc.createTextNode(entry.suppressMissingDependenciesErrors ? constants.True : constants.False);
|
||||
suppressMissingDependenciesErrorNode.appendChild(suppressMissingDependenciesErrorTextNode);
|
||||
referenceNode.appendChild(suppressMissingDependenciesErrorNode);
|
||||
|
||||
if ((<DacpacReferenceProjectEntry>entry).databaseSqlCmdVariable) {
|
||||
@@ -648,6 +655,10 @@ export class Project {
|
||||
const nameNodes = currentNode.getElementsByTagName(constants.DatabaseVariableLiteralValue);
|
||||
const databaseVariableName = nameNodes[0].childNodes[0]?.nodeValue;
|
||||
|
||||
// get suppressMissingDependenciesErrors
|
||||
const suppressMissingDependenciesErrorNode = currentNode.getElementsByTagName(constants.SuppressMissingDependenciesErrors);
|
||||
const suppressMissingDependences = suppressMissingDependenciesErrorNode[0].childNodes[0].nodeValue === true ?? false;
|
||||
|
||||
// remove this node
|
||||
this.projFileXmlDoc.documentElement.removeChild(currentNode);
|
||||
|
||||
@@ -659,7 +670,7 @@ export class Project {
|
||||
// remove from database references because it'll get added again later
|
||||
this.databaseReferences.splice(this.databaseReferences.findIndex(n => n.databaseName === (systemDb === SystemDatabase.master ? constants.master : constants.msdb)), 1);
|
||||
|
||||
await this.addSystemDatabaseReference({ databaseName: databaseVariableName, systemDb: systemDb });
|
||||
await this.addSystemDatabaseReference({ databaseName: databaseVariableName, systemDb: systemDb, suppressMissingDependenciesErrors: suppressMissingDependences });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -778,6 +789,7 @@ export class FileProjectEntry extends ProjectEntry {
|
||||
export interface IDatabaseReferenceProjectEntry extends FileProjectEntry {
|
||||
databaseName: string;
|
||||
databaseVariableLiteralValue?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
}
|
||||
|
||||
export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
@@ -786,6 +798,7 @@ export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDa
|
||||
databaseSqlCmdVariable?: string;
|
||||
serverName?: string;
|
||||
serverSqlCmdVariable?: string;
|
||||
suppressMissingDependenciesErrors: boolean;
|
||||
|
||||
constructor(settings: IDacpacReferenceSettings) {
|
||||
super(settings.dacpacFileLocation, '', EntryType.DatabaseReference);
|
||||
@@ -794,6 +807,7 @@ export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDa
|
||||
this.databaseVariableLiteralValue = settings.databaseName;
|
||||
this.serverName = settings.serverName;
|
||||
this.serverSqlCmdVariable = settings.serverVariable;
|
||||
this.suppressMissingDependenciesErrors = settings.suppressMissingDependenciesErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -805,7 +819,7 @@ export class DacpacReferenceProjectEntry extends FileProjectEntry implements IDa
|
||||
}
|
||||
|
||||
class SystemDatabaseReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
constructor(uri: Uri, public ssdtUri: Uri, public databaseVariableLiteralValue: string) {
|
||||
constructor(uri: Uri, public ssdtUri: Uri, public databaseVariableLiteralValue: string, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(uri, '', EntryType.DatabaseReference);
|
||||
}
|
||||
|
||||
@@ -828,11 +842,8 @@ class SystemDatabaseReferenceProjectEntry extends FileProjectEntry implements ID
|
||||
}
|
||||
|
||||
export class SqlProjectReferenceProjectEntry extends FileProjectEntry implements IDatabaseReferenceProjectEntry {
|
||||
projectName: string;
|
||||
|
||||
constructor(uri: Uri, name: string) {
|
||||
constructor(uri: Uri, public projectName: string, public suppressMissingDependenciesErrors: boolean) {
|
||||
super(uri, '', EntryType.DatabaseReference);
|
||||
this.projectName = name;
|
||||
}
|
||||
|
||||
public get databaseName(): string {
|
||||
|
||||
@@ -191,18 +191,20 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no database references to start with');
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master });
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no datbase references to start with');
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master, suppressMissingDependenciesErrors: false });
|
||||
should(project.databaseReferences.length).equal(1, 'There should be one database reference after adding a reference to master');
|
||||
should(project.databaseReferences[0].databaseName).equal(constants.master, 'The database reference should be master');
|
||||
should(project.databaseReferences[0].suppressMissingDependenciesErrors).equal(false, 'project.databaseReferences[1].suppressMissingDependenciesErrors should be false');
|
||||
// make sure reference to ADS master dacpac and SSDT master dacpac was added
|
||||
let projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacUri(constants.master).fsPath.substring(1)));
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacSsdtUri(constants.master).fsPath.substring(1)));
|
||||
|
||||
await project.addSystemDatabaseReference({ databaseName: 'msdb', systemDb: SystemDatabase.msdb });
|
||||
await project.addSystemDatabaseReference({ databaseName: 'msdb', systemDb: SystemDatabase.msdb, suppressMissingDependenciesErrors: false });
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after adding a reference to msdb');
|
||||
should(project.databaseReferences[1].databaseName).equal(constants.msdb, 'The database reference should be msdb');
|
||||
should(project.databaseReferences[1].suppressMissingDependenciesErrors).equal(false, 'project.databaseReferences[1].suppressMissingDependenciesErrors should be false');
|
||||
// make sure reference to ADS msdb dacpac and SSDT msdb dacpac was added
|
||||
projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql(convertSlashesForSqlProj(project.getSystemDacpacUri(constants.msdb).fsPath.substring(1)));
|
||||
@@ -215,9 +217,10 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
|
||||
// add database reference in the same database
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no database references to start with');
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test1.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase });
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test1.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase, suppressMissingDependenciesErrors: true });
|
||||
should(project.databaseReferences.length).equal(1, 'There should be a database reference after adding a reference to test1');
|
||||
should(project.databaseReferences[0].databaseName).equal('test1', 'The database reference should be test1');
|
||||
should(project.databaseReferences[0].suppressMissingDependenciesErrors).equal(true, 'project.databaseReferences[0].suppressMissingDependenciesErrors should be true');
|
||||
// make sure reference to test.dacpac was added
|
||||
let projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql('test1.dacpac');
|
||||
@@ -233,10 +236,12 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
dacpacFileLocation: Uri.file('test2.dacpac'),
|
||||
databaseLocation: DatabaseReferenceLocation.differentDatabaseSameServer,
|
||||
databaseName: 'test2DbName',
|
||||
databaseVariable: 'test2Db'
|
||||
databaseVariable: 'test2Db',
|
||||
suppressMissingDependenciesErrors: false
|
||||
});
|
||||
should(project.databaseReferences.length).equal(1, 'There should be a database reference after adding a reference to test2');
|
||||
should(project.databaseReferences[0].databaseName).equal('test2', 'The database reference should be test2');
|
||||
should(project.databaseReferences[0].suppressMissingDependenciesErrors).equal(false, 'project.databaseReferences[0].suppressMissingDependenciesErrors should be false');
|
||||
// make sure reference to test2.dacpac and SQLCMD variable was added
|
||||
let projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql('test2.dacpac');
|
||||
@@ -256,10 +261,12 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
databaseName: 'test3DbName',
|
||||
databaseVariable: 'test3Db',
|
||||
serverName: 'otherServerName',
|
||||
serverVariable: 'otherServer'
|
||||
serverVariable: 'otherServer',
|
||||
suppressMissingDependenciesErrors: false
|
||||
});
|
||||
should(project.databaseReferences.length).equal(1, 'There should be a database reference after adding a reference to test3');
|
||||
should(project.databaseReferences[0].databaseName).equal('test3', 'The database reference should be test3');
|
||||
should(project.databaseReferences[0].suppressMissingDependenciesErrors).equal(false, 'project.databaseReferences[0].suppressMissingDependenciesErrors should be false');
|
||||
// make sure reference to test2.dacpac and SQLCMD variables were added
|
||||
let projFileText = (await fs.readFile(projFilePath)).toString();
|
||||
should(projFileText).containEql('test3.dacpac');
|
||||
@@ -274,20 +281,20 @@ describe('Project: sqlproj content operations', function (): void {
|
||||
const project = await Project.openProject(projFilePath);
|
||||
|
||||
should(project.databaseReferences.length).equal(0, 'There should be no database references to start with');
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master });
|
||||
await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master, suppressMissingDependenciesErrors: false });
|
||||
should(project.databaseReferences.length).equal(1, 'There should be one database reference after adding a reference to master');
|
||||
should(project.databaseReferences[0].databaseName).equal(constants.master, 'project.databaseReferences[0].databaseName should be master');
|
||||
|
||||
// try to add reference to master again
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master }), constants.databaseReferenceAlreadyExists);
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addSystemDatabaseReference({ databaseName: 'master', systemDb: SystemDatabase.master, suppressMissingDependenciesErrors: false }), constants.databaseReferenceAlreadyExists);
|
||||
should(project.databaseReferences.length).equal(1, 'There should only be one database reference after trying to add a reference to master again');
|
||||
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase });
|
||||
await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase, suppressMissingDependenciesErrors: false });
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after adding a reference to test.dacpac');
|
||||
should(project.databaseReferences[1].databaseName).equal('test', 'project.databaseReferences[1].databaseName should be test');
|
||||
|
||||
// try to add reference to test.dacpac again
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase }), constants.databaseReferenceAlreadyExists);
|
||||
await testUtils.shouldThrowSpecificError(async () => await project.addDatabaseReference({ dacpacFileLocation: Uri.file('test.dacpac'), databaseLocation: DatabaseReferenceLocation.sameDatabase, suppressMissingDependenciesErrors: false }), constants.databaseReferenceAlreadyExists);
|
||||
should(project.databaseReferences.length).equal(2, 'There should be two database references after trying to add a reference to test.dacpac again');
|
||||
});
|
||||
|
||||
|
||||
@@ -522,9 +522,9 @@ describe('ProjectsController', function (): void {
|
||||
const addDbReferenceDialog = TypeMoq.Mock.ofType(AddDatabaseReferenceDialog, undefined, undefined, proj);
|
||||
addDbReferenceDialog.callBase = true;
|
||||
addDbReferenceDialog.setup(x => x.addReferenceClick()).returns(() => {
|
||||
projController.object.addDatabaseReferenceCallback(proj, { systemDb: SystemDatabase.master, databaseName: 'master' });
|
||||
projController.object.addDatabaseReferenceCallback(proj, { systemDb: SystemDatabase.master, databaseName: 'master', suppressMissingDependenciesErrors: false });
|
||||
return Promise.resolve(undefined);
|
||||
})
|
||||
});
|
||||
|
||||
const projController = TypeMoq.Mock.ofType(ProjectsController);
|
||||
projController.callBase = true;
|
||||
|
||||
Reference in New Issue
Block a user