mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 01:25:40 -05:00
Fix tools service crash + improve server edition naming (#506)
* Fix https://github.com/Microsoft/vscode-mssql/issues/986 and add better server edition naming - Fixed a number of issues related to the binding queue, specifically the fact that it didn't capture exceptions that occurred on the binding thread. This caused the thread to crash the service. - The root cause of the error was when you get a connection error during init of the SmoMetadataProvider which threw an exception. Because of this no Binder was created, and the code would null ref later during processing - Added logic to handle null ref issue and other related code - Added a unit test for the new error handling path, and supported still returning some value in this case - Separately, have a fix for an issue where the edition is shown as "SQL Azure" for all Azure connections. Fixing to be "Azure SQL DB" for this case and handle when the database reports as DW or Stretch instead. This maps better to users concept of what the edition should be and avoids returning what is an outdated term. * Messed up the test - fixing this by returning the expected return object
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
public class ConnectionService
|
||||
{
|
||||
public const string AdminConnectionPrefix = "ADMIN:";
|
||||
private const string SqlAzureEdition = "SQL Azure";
|
||||
|
||||
/// <summary>
|
||||
/// Singleton service instance
|
||||
@@ -456,7 +457,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
EngineEditionId = serverInfo.EngineEditionId,
|
||||
ServerVersion = serverInfo.ServerVersion,
|
||||
ServerLevel = serverInfo.ServerLevel,
|
||||
ServerEdition = serverInfo.ServerEdition,
|
||||
ServerEdition = MapServerEdition(serverInfo),
|
||||
IsCloud = serverInfo.IsCloud,
|
||||
AzureVersion = serverInfo.AzureVersion,
|
||||
OsVersion = serverInfo.OsVersion,
|
||||
@@ -474,6 +475,31 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
return response;
|
||||
}
|
||||
|
||||
private string MapServerEdition(ReliableConnectionHelper.ServerInfo serverInfo)
|
||||
{
|
||||
string serverEdition = serverInfo.ServerEdition;
|
||||
if (string.IsNullOrWhiteSpace(serverEdition))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (SqlAzureEdition.Equals(serverEdition, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
switch(serverInfo.EngineEditionId)
|
||||
{
|
||||
case (int) DatabaseEngineEdition.SqlDataWarehouse:
|
||||
serverEdition = SR.AzureSqlDwEdition;
|
||||
break;
|
||||
case (int) DatabaseEngineEdition.SqlStretchDatabase:
|
||||
serverEdition = SR.AzureSqlStretchEdition;
|
||||
break;
|
||||
default:
|
||||
serverEdition = SR.AzureSqlDbEdition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return serverEdition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to create and open a connection with the given ConnectParams.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user