mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
use the actual unique id to compare connection (#17229)
* use the actual unique id to compare connection * fix test error and pr comments
This commit is contained in:
@@ -7,7 +7,6 @@ import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectio
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { ProviderConnectionInfo } from 'sql/platform/connection/common/providerConnectionInfo';
|
import { ProviderConnectionInfo } from 'sql/platform/connection/common/providerConnectionInfo';
|
||||||
import * as interfaces from 'sql/platform/connection/common/interfaces';
|
import * as interfaces from 'sql/platform/connection/common/interfaces';
|
||||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
|
||||||
import { generateUuid } from 'vs/base/common/uuid';
|
import { generateUuid } from 'vs/base/common/uuid';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { isString } from 'vs/base/common/types';
|
import { isString } from 'vs/base/common/types';
|
||||||
@@ -83,15 +82,8 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
|||||||
this.options['databaseDisplayName'] = this.databaseName;
|
this.options['databaseDisplayName'] = this.databaseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static matchesProfile(a: interfaces.IConnectionProfile, b: interfaces.IConnectionProfile): boolean {
|
public static matchesProfile(a: interfaces.IConnectionProfile | undefined, b: interfaces.IConnectionProfile | undefined): boolean {
|
||||||
return a && b
|
return a && b && a.getOptionsKey() === b.getOptionsKey();
|
||||||
&& a.providerName === b.providerName
|
|
||||||
&& ConnectionProfile.nullCheckEqualsIgnoreCase(a.serverName, b.serverName)
|
|
||||||
&& ConnectionProfile.nullCheckEqualsIgnoreCase(a.databaseName, b.databaseName)
|
|
||||||
&& ConnectionProfile.nullCheckEqualsIgnoreCase(a.userName, b.userName)
|
|
||||||
&& ConnectionProfile.nullCheckEqualsIgnoreCase(a.options['databaseDisplayName'], b.options['databaseDisplayName'])
|
|
||||||
&& a.authenticationType === b.authenticationType
|
|
||||||
&& a.groupId === b.groupId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public matches(other: interfaces.IConnectionProfile): boolean {
|
public matches(other: interfaces.IConnectionProfile): boolean {
|
||||||
@@ -99,15 +91,6 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static nullCheckEqualsIgnoreCase(a?: string, b?: string) {
|
|
||||||
if (a && !b || b && !a) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
let bothNull: boolean = !a && !b;
|
|
||||||
return bothNull ? bothNull : equalsIgnoreCase(a!, b!);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public generateNewId() {
|
public generateNewId() {
|
||||||
this._id = generateUuid();
|
this._id = generateUuid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ suite('SQL ConnectionStatusManager tests', () => {
|
|||||||
newConnection.options['databaseDisplayName'] = newConnection.databaseName;
|
newConnection.options['databaseDisplayName'] = newConnection.databaseName;
|
||||||
connections.addConnection(newConnection, 'test_uri_1');
|
connections.addConnection(newConnection, 'test_uri_1');
|
||||||
connections.addConnection(newConnection, 'test_uri_2');
|
connections.addConnection(newConnection, 'test_uri_2');
|
||||||
|
newConnection = new ConnectionProfile(capabilitiesService, newConnection);
|
||||||
|
|
||||||
// Get the connections and verify that the duplicate is only returned once
|
// Get the connections and verify that the duplicate is only returned once
|
||||||
let activeConnections = connections.getActiveConnectionProfiles();
|
let activeConnections = connections.getActiveConnectionProfiles();
|
||||||
|
|||||||
Reference in New Issue
Block a user