From 1b5f7747417cd17dd3be7dfbc0459d0ccbb748f9 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Fri, 5 May 2023 10:11:54 -0700 Subject: [PATCH] Reverting Connection URI related changes for stable release (#2042) --- .../Connection/Contracts/ConnectionDetails.cs | 15 ------ .../LanguageServices/ConnectedBindingQueue.cs | 50 +++---------------- .../TableDesigner/TableDesignerService.cs | 7 +-- .../ObjectExplorerServiceTests.cs | 2 +- 4 files changed, 10 insertions(+), 64 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectionDetails.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectionDetails.cs index ccaff015..0c6397f6 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectionDetails.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/Contracts/ConnectionDetails.cs @@ -586,21 +586,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts } } - /// - /// Gets or sets the connection name - /// - public string ConnectionName - { - get - { - return GetOptionValue("connectionName"); - } - set - { - SetOptionValue("connectionName", value); - } - } - /// /// Gets or sets the database display name /// diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs index 3b8905e3..2e7b30f3 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.SmoMetadataProvider; using Microsoft.SqlServer.Management.SqlParser.Binder; @@ -71,7 +70,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices public ConnectedBindingQueue() : this(true) - { + { } public ConnectedBindingQueue(bool needsMetadata) @@ -91,7 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices /// /// internal static string GetConnectionContextKey(ConnectionDetails details) - { + { string key = string.Format("{0}_{1}_{2}_{3}", details.ServerName ?? "NULL", details.DatabaseName ?? "NULL", @@ -109,39 +108,6 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices key += "_" + details.GroupId; } - if (!string.IsNullOrEmpty(details.ConnectionName)) - { - key += "_" + details.ConnectionName; - } - - // Additional properties that are used to distinguish the connection (besides password) - // These are so that multiple connections can connect to the same target, with different settings. - foreach (KeyValuePair entry in details.Options) - { - // Filter out properties we already have or don't want (password) - if (entry.Key != "server" && entry.Key != "database" && entry.Key != "user" - && entry.Key != "authenticationType" && entry.Key != "databaseDisplayName" - && entry.Key != "groupId" && entry.Key != "password" && entry.Key != "connectionName") - { - // Boolean values are explicitly labeled true or false instead of undefined. - if (entry.Value is bool) - { - if ((bool)entry.Value) - { - key += "_" + entry.Key + ":true"; - } - else - { - key += "_" + entry.Key + ":false"; - } - } - else if (!string.IsNullOrEmpty(entry.Value as String)) - { - key += "_" + entry.Key + ":" + entry.Value; - } - } - } - return Uri.EscapeUriString(key); } @@ -154,7 +120,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices return string.Format("{0}_{1}", serverName ?? "NULL", databaseName ?? "NULL"); - + } public void CloseConnections(string serverName, string databaseName, int millisecondsTimeout) @@ -232,7 +198,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices try { bindingContext.BindingLock.Reset(); - + // populate the binding context to work with the SMO metadata provider bindingContext.ServerConnection = connectionOpener.OpenServerConnection(connInfo, featureName); @@ -244,19 +210,19 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices this.CurrentSettings.SqlTools.IntelliSense.LowerCaseSuggestions.Value ? CasingStyle.Lowercase : CasingStyle.Uppercase; bindingContext.Binder = BinderProvider.CreateBinder(bindingContext.SmoMetadataProvider); - } - + } + bindingContext.BindingTimeout = ConnectedBindingQueue.DefaultBindingTimeout; bindingContext.IsConnected = true; } catch (Exception) { bindingContext.IsConnected = false; - } + } finally { bindingContext.BindingLock.Set(); - } + } } return connectionKey; diff --git a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs index 36a4e5ae..3d409b91 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/TableDesigner/TableDesignerService.cs @@ -1831,14 +1831,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner private void UpdateTableTitleInfo(TableInfo tableInfo) { var td = GetTableDesigner(tableInfo); - var advancedOpsIndex = tableInfo.Tooltip.LastIndexOf('['); - var advancedOps = ""; - if(advancedOpsIndex > -1){ - advancedOps = " " + tableInfo.Tooltip.Substring(advancedOpsIndex); - } tableInfo.Title = td.TableViewModel.FullName; var tableParent = tableInfo.Server == null ? tableInfo.ProjectFilePath : string.Format("{0} - {1}", tableInfo.Server, tableInfo.Database); - tableInfo.Tooltip = string.Format("{0} - {1}{2}", tableParent, tableInfo.Title, advancedOps); + tableInfo.Tooltip = string.Format("{0} - {1}", tableParent, tableInfo.Title); } private Dictionary GetMetadata(TableInfo tableInfo) diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs index d340b16a..2ebd0198 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/ObjectExplorerServiceTests.cs @@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer ConnectedBindingContext connectedBindingContext = new ConnectedBindingContext(); connectedBindingContext.ServerConnection = new ServerConnection(new SqlConnection(fakeConnectionString)); connectedBindingQueue = new ConnectedBindingQueue(false); - connectedBindingQueue.BindingContextMap.Add($"{details.ServerName}_{details.DatabaseName}_{details.UserName}_NULL_persistSecurityInfo:true", connectedBindingContext); + connectedBindingQueue.BindingContextMap.Add($"{details.ServerName}_{details.DatabaseName}_{details.UserName}_NULL", connectedBindingContext); connectedBindingQueue.BindingContextTasks.Add(connectedBindingContext, Task.Run(() => null)); mockConnectionOpener = new Mock(); connectedBindingQueue.SetConnectionOpener(mockConnectionOpener.Object);