13159 Created SetDatabaseName in KustoClient to take database name from ( ). Changed ListDatabases in Kusto ConnnectionService to set DatabaseNames in a different format when the PrettyName doesn't match the name. (#1123)

This commit is contained in:
Justin M
2020-11-19 14:18:58 -08:00
committed by GitHub
parent 6e83077fb7
commit 67c7e20c13
2 changed files with 24 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Kusto.Cloud.Platform.Data;
@@ -42,11 +43,23 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
{
_ownerUri = ownerUri;
ClusterName = GetClusterName(connectionString);
DatabaseName = new SqlConnectionStringBuilder(connectionString).InitialCatalog;
var dbName = new SqlConnectionStringBuilder(connectionString).InitialCatalog;
SetDatabaseName(dbName);
Initialize(ClusterName, DatabaseName, azureAccountToken);
SchemaState = LoadSchemaState();
}
private void SetDatabaseName(string databaseName)
{
var regex = new Regex(@"(?<=\().+?(?=\))");
DatabaseName = regex.IsMatch(databaseName)
? regex.Match(databaseName).Value
: databaseName;
}
private GlobalState LoadSchemaState()
{
IEnumerable<ShowDatabaseSchemaResult> tableSchemas = Enumerable.Empty<ShowDatabaseSchemaResult>();
@@ -297,7 +310,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
public void UpdateDatabase(string databaseName)
{
DatabaseName = databaseName;
SetDatabaseName(databaseName);
SchemaState = LoadSchemaState();
}