Detect system connection for OE if database display name is blank (#583)

This commit is contained in:
Matt Irvine
2018-02-12 11:13:03 -08:00
committed by GitHub
parent c40c740a73
commit 0eaf60c93a
3 changed files with 21 additions and 4 deletions

View File

@@ -458,7 +458,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
ObjectExplorerSession session = null;
connectionDetails.PersistSecurityInfo = true;
ConnectParams connectParams = new ConnectParams() { OwnerUri = uri, Connection = connectionDetails, Type = Connection.ConnectionType.ObjectExplorer };
string connectionDatabase = connectionDetails.DatabaseName;
bool isDefaultOrSystemDatabase = DatabaseUtils.IsSystemDatabaseConnection(connectionDetails.DatabaseName) || string.IsNullOrWhiteSpace(connectionDetails.DatabaseDisplayName);
ConnectionInfo connectionInfo;
ConnectionCompleteParams connectionResult = await Connect(connectParams, uri);
@@ -480,7 +480,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
waitForLockTimeout: timeout,
bindOperation: (bindingContext, cancelToken) =>
{
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection, connectionDatabase);
session = ObjectExplorerSession.CreateSession(connectionResult, serviceProvider, bindingContext.ServerConnection, isDefaultOrSystemDatabase);
session.ConnectionInfo = connectionInfo;
sessionMap.AddOrUpdate(uri, session, (key, oldSession) => session);
@@ -729,11 +729,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
public string ErrorMessage { get; set; }
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection, string connectionDatabase)
public static ObjectExplorerSession CreateSession(ConnectionCompleteParams response, IMultiServiceProvider serviceProvider, ServerConnection serverConnection, bool isDefaultOrSystemDatabase)
{
ServerNode rootNode = new ServerNode(response, serviceProvider, serverConnection);
var session = new ObjectExplorerSession(response.OwnerUri, rootNode, serviceProvider, serviceProvider.GetService<ConnectionService>());
if (!DatabaseUtils.IsSystemDatabaseConnection(connectionDatabase))
if (!isDefaultOrSystemDatabase)
{
// Assuming the databases are in a folder under server node
DatabaseTreeNode databaseNode = new DatabaseTreeNode(rootNode, response.ConnectionSummary.DatabaseName);