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;
|
databaseName: string;
|
||||||
ownerUri: string;
|
ownerUri: string;
|
||||||
connectionDetails: azdata.ConnectionInfo;
|
connectionDetails: azdata.ConnectionInfo;
|
||||||
|
connectionName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SchemaCompareObjectId {
|
export interface SchemaCompareObjectId {
|
||||||
|
|||||||
@@ -100,16 +100,18 @@ export class SchemaCompareDialog {
|
|||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
} else {
|
} 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 = {
|
this.schemaCompareMainWindow.sourceEndpointInfo = {
|
||||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||||
serverDisplayName: (this.sourceServerDropdown.value as ConnectionDropdownValue).displayName,
|
serverDisplayName: sourceServerDropdownValue.displayName,
|
||||||
serverName: (this.sourceServerDropdown.value as ConnectionDropdownValue).name,
|
serverName: sourceServerDropdownValue.name,
|
||||||
databaseName: this.sourceDatabaseDropdown.value.toString(),
|
databaseName: this.sourceDatabaseDropdown.value.toString(),
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined,
|
||||||
|
connectionName: sourceServerDropdownValue.connection.options.connectionName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,16 +126,18 @@ export class SchemaCompareDialog {
|
|||||||
connectionDetails: undefined
|
connectionDetails: undefined
|
||||||
};
|
};
|
||||||
} else {
|
} 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 = {
|
this.schemaCompareMainWindow.targetEndpointInfo = {
|
||||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||||
serverDisplayName: (this.targetServerDropdown.value as ConnectionDropdownValue).displayName,
|
serverDisplayName: targetServerDropdownValue.displayName,
|
||||||
serverName: (this.targetServerDropdown.value as ConnectionDropdownValue).name,
|
serverName: targetServerDropdownValue.name,
|
||||||
databaseName: this.targetDatabaseDropdown.value.toString(),
|
databaseName: this.targetDatabaseDropdown.value.toString(),
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined,
|
||||||
|
connectionName: targetServerDropdownValue.connection.options.connectionName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,12 +98,13 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
this.sourceEndpointInfo = {
|
this.sourceEndpointInfo = {
|
||||||
endpointType: mssql.SchemaCompareEndpointType.Database,
|
endpointType: mssql.SchemaCompareEndpointType.Database,
|
||||||
serverDisplayName: profile.connectionName ? profile.connectionName : profile.serverName,
|
serverDisplayName: `${profile.serverName} (${usr})`,
|
||||||
serverName: profile.serverName,
|
serverName: profile.serverName,
|
||||||
databaseName: profile.databaseName,
|
databaseName: profile.databaseName,
|
||||||
ownerUri: ownerUri,
|
ownerUri: ownerUri,
|
||||||
packageFilePath: '',
|
packageFilePath: '',
|
||||||
connectionDetails: undefined
|
connectionDetails: undefined,
|
||||||
|
connectionName: profile.connectionName
|
||||||
};
|
};
|
||||||
} else if (sourceDacpac) {
|
} else if (sourceDacpac) {
|
||||||
this.sourceEndpointInfo = {
|
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', () => {
|
it('Should get only database information from ConnectionInfo if connection', () => {
|
||||||
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
||||||
testDatabaseEndpoint.serverDisplayName = 'My Connection';
|
|
||||||
testDatabaseEndpoint.connectionDetails = { ...mockConnectionInfo };
|
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');
|
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', () => {
|
it('Should get correct endpoint information from SchemaCompareEndpointInfo', () => {
|
||||||
const dbName = 'My Database';
|
const dbName = 'My Database';
|
||||||
const serverDisplayName = 'My Connection';
|
const serverName = 'My Server';
|
||||||
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
const testDatabaseEndpoint: mssql.SchemaCompareEndpointInfo = { ...mockDatabaseEndpoint };
|
||||||
testDatabaseEndpoint.databaseName = dbName;
|
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');
|
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.endpointType === mssql.SchemaCompareEndpointType.Database) {
|
||||||
if (!endpoint.serverDisplayName && endpoint.connectionDetails) {
|
if (!endpoint.serverName && endpoint.connectionDetails) {
|
||||||
endpoint.serverDisplayName = endpoint.connectionDetails['serverName'];
|
endpoint.serverName = endpoint.connectionDetails['serverName'];
|
||||||
}
|
}
|
||||||
if (!endpoint.databaseName && endpoint.connectionDetails) {
|
if (!endpoint.databaseName && endpoint.connectionDetails) {
|
||||||
endpoint.databaseName = endpoint.connectionDetails['databaseName'];
|
endpoint.databaseName = endpoint.connectionDetails['databaseName'];
|
||||||
}
|
}
|
||||||
if (endpoint.serverDisplayName && endpoint.databaseName) {
|
if (endpoint.connectionName && endpoint.databaseName) {
|
||||||
return `${endpoint.serverDisplayName}.${endpoint.databaseName}`;
|
return `${endpoint.connectionName}.${endpoint.databaseName}`;
|
||||||
|
}
|
||||||
|
if (endpoint.serverName && endpoint.databaseName) {
|
||||||
|
return `${endpoint.serverName}.${endpoint.databaseName}`;
|
||||||
} else {
|
} else {
|
||||||
return ' ';
|
return ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user