mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fix schema compare display name having username (#15357)
* fix schema compare display name having username * reuse variable * fix previous selection for server not being selected in dialog * fix tests
This commit is contained in:
1
extensions/mssql/src/mssql.d.ts
vendored
1
extensions/mssql/src/mssql.d.ts
vendored
@@ -129,6 +129,7 @@ export interface SchemaCompareEndpointInfo {
|
||||
databaseName: string;
|
||||
ownerUri: string;
|
||||
connectionDetails: azdata.ConnectionInfo;
|
||||
connectionName?: string;
|
||||
}
|
||||
|
||||
export interface SchemaCompareObjectId {
|
||||
|
||||
@@ -100,16 +100,18 @@ export class SchemaCompareDialog {
|
||||
connectionDetails: undefined
|
||||
};
|
||||
} else {
|
||||
let ownerUri = await azdata.connection.getUriForConnection((this.sourceServerDropdown.value as ConnectionDropdownValue).connection.connectionId);
|
||||
const sourceServerDropdownValue = this.sourceServerDropdown.value as ConnectionDropdownValue;
|
||||
const ownerUri = await azdata.connection.getUriForConnection(sourceServerDropdownValue.connection.connectionId);
|
||||
|
||||
this.schemaCompareMainWindow.sourceEndpointInfo = {
|
||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||
serverDisplayName: (this.sourceServerDropdown.value as ConnectionDropdownValue).displayName,
|
||||
serverName: (this.sourceServerDropdown.value as ConnectionDropdownValue).name,
|
||||
serverDisplayName: sourceServerDropdownValue.displayName,
|
||||
serverName: sourceServerDropdownValue.name,
|
||||
databaseName: this.sourceDatabaseDropdown.value.toString(),
|
||||
ownerUri: ownerUri,
|
||||
packageFilePath: '',
|
||||
connectionDetails: undefined
|
||||
connectionDetails: undefined,
|
||||
connectionName: sourceServerDropdownValue.connection.options.connectionName
|
||||
};
|
||||
}
|
||||
|
||||
@@ -124,16 +126,18 @@ export class SchemaCompareDialog {
|
||||
connectionDetails: undefined
|
||||
};
|
||||
} else {
|
||||
let ownerUri = await azdata.connection.getUriForConnection((this.targetServerDropdown.value as ConnectionDropdownValue).connection.connectionId);
|
||||
const targetServerDropdownValue = this.targetServerDropdown.value as ConnectionDropdownValue;
|
||||
const ownerUri = await azdata.connection.getUriForConnection(targetServerDropdownValue.connection.connectionId);
|
||||
|
||||
this.schemaCompareMainWindow.targetEndpointInfo = {
|
||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||
serverDisplayName: (this.targetServerDropdown.value as ConnectionDropdownValue).displayName,
|
||||
serverName: (this.targetServerDropdown.value as ConnectionDropdownValue).name,
|
||||
serverDisplayName: targetServerDropdownValue.displayName,
|
||||
serverName: targetServerDropdownValue.name,
|
||||
databaseName: this.targetDatabaseDropdown.value.toString(),
|
||||
ownerUri: ownerUri,
|
||||
packageFilePath: '',
|
||||
connectionDetails: undefined
|
||||
connectionDetails: undefined,
|
||||
connectionName: targetServerDropdownValue.connection.options.connectionName
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -98,12 +98,13 @@ export class SchemaCompareMainWindow {
|
||||
|
||||
this.sourceEndpointInfo = {
|
||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||
serverDisplayName: profile.connectionName ? profile.connectionName : profile.serverName,
|
||||
serverDisplayName: `${profile.serverName} (${usr})`,
|
||||
serverName: profile.serverName,
|
||||
databaseName: profile.databaseName,
|
||||
ownerUri: ownerUri,
|
||||
packageFilePath: '',
|
||||
connectionDetails: undefined
|
||||
connectionDetails: undefined,
|
||||
connectionName: profile.connectionName
|
||||
};
|
||||
} else if (sourceDacpac) {
|
||||
this.sourceEndpointInfo = {
|
||||
|
||||
@@ -35,9 +35,12 @@ describe('utils: Tests to verify getEndpointName @DacFx@', function (): void {
|
||||
|
||||
it('Should get only database information from ConnectionInfo if connection', () => {
|
||||
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
||||
testDatabaseEndpoint.serverDisplayName = 'My Connection';
|
||||
testDatabaseEndpoint.connectionDetails = { ...mockConnectionInfo };
|
||||
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Server.My Database');
|
||||
|
||||
// set connection name and connection name should be used in endpoint name
|
||||
testDatabaseEndpoint.connectionName = 'My Connection';
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Connection.My Database');
|
||||
});
|
||||
|
||||
@@ -50,11 +53,14 @@ describe('utils: Tests to verify getEndpointName @DacFx@', function (): void {
|
||||
|
||||
it('Should get correct endpoint information from SchemaCompareEndpointInfo', () => {
|
||||
const dbName = 'My Database';
|
||||
const serverDisplayName = 'My Connection';
|
||||
const serverName = 'My Server';
|
||||
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
||||
testDatabaseEndpoint.databaseName = dbName;
|
||||
testDatabaseEndpoint.serverDisplayName = serverDisplayName;
|
||||
testDatabaseEndpoint.serverName = serverName;
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Server.My Database');
|
||||
|
||||
// set connection name and verify endpoint name uses connection name
|
||||
testDatabaseEndpoint.connectionName = 'My Connection';
|
||||
should(getEndpointName(testDatabaseEndpoint)).equal('My Connection.My Database');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,14 +49,17 @@ export function getEndpointName(endpoint: mssql.SchemaCompareEndpointInfo): stri
|
||||
}
|
||||
|
||||
if (endpoint.endpointType === mssql.SchemaCompareEndpointType.Database) {
|
||||
if (!endpoint.serverDisplayName && endpoint.connectionDetails) {
|
||||
endpoint.serverDisplayName = endpoint.connectionDetails['serverName'];
|
||||
if (!endpoint.serverName && endpoint.connectionDetails) {
|
||||
endpoint.serverName = endpoint.connectionDetails['serverName'];
|
||||
}
|
||||
if (!endpoint.databaseName && endpoint.connectionDetails) {
|
||||
endpoint.databaseName = endpoint.connectionDetails['databaseName'];
|
||||
}
|
||||
if (endpoint.serverDisplayName && endpoint.databaseName) {
|
||||
return `${endpoint.serverDisplayName}.${endpoint.databaseName}`;
|
||||
if (endpoint.connectionName && endpoint.databaseName) {
|
||||
return `${endpoint.connectionName}.${endpoint.databaseName}`;
|
||||
}
|
||||
if (endpoint.serverName && endpoint.databaseName) {
|
||||
return `${endpoint.serverName}.${endpoint.databaseName}`;
|
||||
} else {
|
||||
return ' ';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user