Fixing OE database expansion read only datamarts databases (#1991)

This commit is contained in:
Aasim Khan
2023-04-06 01:34:46 -07:00
committed by GitHub
parent b48f1f2833
commit 319af30665
2 changed files with 26 additions and 4 deletions

View File

@@ -79,8 +79,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
}
catch (Exception ex)
{
// IsAccessible is not set of DW Gen3 so exception is expected in this case
if (IsDWGen3(context?.Database))
// IsAccessible is not set of DW Gen3 and Dataverse so exception is expected in this case
// Incase of dataverses and other TDS endpoints isAccessible creates a temp table to check if the database
// is accessible, however these endpoints may not support ddl statements and therefore the check fails.
if (IsDWGen3(context?.Database) || isUnknownDatabaseEdition(context?.Database))
{
return true;
}
@@ -102,5 +104,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
&& db.DatabaseEngineEdition == DatabaseEngineEdition.SqlDataWarehouse
&& db.ServerVersion.Major == 12;
}
private bool isUnknownDatabaseEdition(Database db)
{
// If the database engine edition is not defined in the enum, it is an unknown edition
return db != null
&& !Enum.IsDefined(typeof(DatabaseEngineEdition), db.DatabaseEngineEdition);
}
}
}

View File

@@ -9,6 +9,7 @@ using System;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
{
@@ -41,7 +42,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
/// </summary>
public static ValidForFlag GetValidForFlag(SqlServerType serverType, Database database = null)
{
return GetValidForFlag(serverType, database != null && database.IsSqlDw);
var isSqlDw = false;
try
{
isSqlDw = database.IsSqlDw;
}
catch (Exception e)
{
// Incase of dataverses, isSqlDw creates a temp table to check if the database is accessible, however dataverse
// don't support ddl statements and therefore this check fails.
Logger.Information($"This exception is expected when we are trying to access a readonly database. Exception: {e.Message}");
}
return GetValidForFlag(serverType, database != null && isSqlDw);
}
/// <summary>