Update schema compare extension to support SQL Login (#8567)

* Update schema compare extension to support SQL Login

* Update schema compare extension to support SQL Login

* Fixed the scenario where scmp file doesn't open as expected- cleaning up previous connect information and setting appropriate button states if either source or target info is missing. Also updated function getEndpointName to return empty string if serverName and databaseName aren't present, instead of partial information.

* Addressed comments. Fixed var names and moved repeatitive code in a helper function.
This commit is contained in:
Sakshi Sharma
2019-12-06 11:52:48 -08:00
committed by GitHub
parent 7cd2a6d6aa
commit 794f7a14c0
2 changed files with 80 additions and 49 deletions

View File

@@ -23,6 +23,8 @@ const generateScriptNoChangesMessage = localize('schemaCompare.generateScriptNoC
const applyEnabledMessage = localize('schemaCompare.applyButtonEnabledTitle', "Apply changes to target");
const applyNoChangesMessage = localize('schemaCompare.applyNoChanges', "No changes to apply");
const includeExcludeInfoMessage = localize('schemaCompare.includeExcludeInfoMessage', "Please note that include/exclude operations can take a moment to calculate affected dependencies");
const sourceTitle = localize('schemaCompareDialog.SourceTitle', "Source");
const targetTitle = localize('schemaCompareDialog.TargetTitle', "Target");
// Do not localize this, this is used to decide the icon for the editor.
// TODO : In future icon should be decided based on language id (scmp) and not resource name
@@ -256,8 +258,12 @@ export class SchemaCompareMainWindow {
},
]);
// reset buttons to before comparison state
this.resetButtons(ResetButtonState.beforeCompareStart);
if (!this.sourceName || !this.targetName || this.sourceName === ' ' || this.targetName === ' ') {
this.resetButtons(ResetButtonState.noSourceTarget);
} else {
// reset buttons to before comparison state
this.resetButtons(ResetButtonState.beforeCompareStart);
}
}
// only for test
@@ -819,7 +825,6 @@ export class SchemaCompareMainWindow {
// reset state afer loading an scmp
private resetForNewCompare(): void {
this.resetButtons(ResetButtonState.beforeCompareStart);
this.flexModel.removeItem(this.splitView);
this.flexModel.removeItem(this.noDifferencesLabel);
this.flexModel.addItem(this.startText, { CSSStyles: { 'margin': 'auto' } });
@@ -941,44 +946,8 @@ export class SchemaCompareMainWindow {
return;
}
if (result.sourceEndpointInfo && result.sourceEndpointInfo.endpointType === mssql.SchemaCompareEndpointType.Database) {
// only set endpoint info if able to connect to the database
const ownerUri = await verifyConnectionAndGetOwnerUri(result.sourceEndpointInfo);
if (ownerUri) {
this.sourceEndpointInfo = result.sourceEndpointInfo;
this.sourceEndpointInfo.ownerUri = ownerUri;
}
} else {
// need to do this instead of just setting it to the result.sourceEndpointInfo because some fields are null which will cause an error when sending the compare request
this.sourceEndpointInfo = {
endpointType: mssql.SchemaCompareEndpointType.Dacpac,
serverDisplayName: '',
serverName: '',
databaseName: '',
ownerUri: '',
packageFilePath: result.sourceEndpointInfo.packageFilePath,
connectionDetails: undefined
};
}
if (result.targetEndpointInfo && result.targetEndpointInfo.endpointType === mssql.SchemaCompareEndpointType.Database) {
const ownerUri = await verifyConnectionAndGetOwnerUri(result.targetEndpointInfo);
if (ownerUri) {
this.targetEndpointInfo = result.targetEndpointInfo;
this.targetEndpointInfo.ownerUri = ownerUri;
}
} else {
// need to do this instead of just setting it to the result.targetEndpointInfo because some fields are null which will cause an error when sending the compare request
this.targetEndpointInfo = {
endpointType: mssql.SchemaCompareEndpointType.Dacpac,
serverDisplayName: '',
serverName: '',
databaseName: '',
ownerUri: '',
packageFilePath: result.targetEndpointInfo.packageFilePath,
connectionDetails: undefined
};
}
this.sourceEndpointInfo = await this.constructEndpointInfo(result.sourceEndpointInfo, sourceTitle);
this.targetEndpointInfo = await this.constructEndpointInfo(result.targetEndpointInfo, targetTitle);
this.updateSourceAndTarget();
this.setDeploymentOptions(result.deploymentOptions);
@@ -995,6 +964,31 @@ export class SchemaCompareMainWindow {
});
}
private async constructEndpointInfo(endpoint: mssql.SchemaCompareEndpointInfo, caller: string): Promise<mssql.SchemaCompareEndpointInfo> {
let ownerUri;
let endpointInfo;
if (endpoint && endpoint.endpointType === mssql.SchemaCompareEndpointType.Database) {
// only set endpoint info if able to connect to the database
ownerUri = await verifyConnectionAndGetOwnerUri(endpoint, caller);
}
if (ownerUri) {
endpointInfo = endpoint;
endpointInfo.ownerUri = ownerUri;
} else {
// need to do this instead of just setting it to the endpoint because some fields are null which will cause an error when sending the compare request
endpointInfo = {
endpointType: endpoint.endpointType === mssql.SchemaCompareEndpointType.Database ? mssql.SchemaCompareEndpointType.Database : mssql.SchemaCompareEndpointType.Dacpac,
serverDisplayName: '',
serverName: '',
databaseName: '',
ownerUri: '',
packageFilePath: endpoint.packageFilePath,
connectionDetails: undefined
};
}
return endpointInfo;
}
private createSaveScmpButton(view: azdata.ModelView): void {
this.saveScmpButton = view.modelBuilder.button().withProperties({
label: localize('schemaCompare.saveScmpButton', "Save .scmp file"),