diff --git a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoClient.cs b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoClient.cs index db767be5..f3603b83 100644 --- a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoClient.cs +++ b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoClient.cs @@ -3,7 +3,6 @@ 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; @@ -39,15 +38,6 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource Initialize(connectionDetails); } - private string ParseDatabaseName(string databaseName) - { - var regex = new Regex(@"(?<=\().+?(?=\))"); - - return regex.IsMatch(databaseName) - ? regex.Match(databaseName).Value - : databaseName; - } - private void Initialize(DataSourceConnectionDetails connectionDetails) { var stringBuilder = GetKustoConnectionStringBuilder(connectionDetails); @@ -88,7 +78,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource : new KustoConnectionStringBuilder(connectionDetails.ConnectionString); ClusterName = stringBuilder.DataSource; - var databaseName = ParseDatabaseName(stringBuilder.InitialCatalog); + var databaseName = KustoQueryUtils.ParseDatabaseName(stringBuilder.InitialCatalog); DatabaseName = databaseName; stringBuilder.InitialCatalog = databaseName; @@ -250,7 +240,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource public void UpdateDatabase(string databaseName) { - DatabaseName = ParseDatabaseName(databaseName); + DatabaseName = databaseName; } public void Dispose() diff --git a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs index ba54f84b..4739f783 100644 --- a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs +++ b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoDataSource.cs @@ -248,8 +248,10 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource /// public override void UpdateDatabase(string databaseName) { - _kustoClient.UpdateDatabase(databaseName); - _intellisenseClient.UpdateDatabase(databaseName); + // Aria has a GUID as a database name so parse it from the display name + var parsedDatabase = KustoQueryUtils.ParseDatabaseName(databaseName); + _kustoClient.UpdateDatabase(parsedDatabase); + _intellisenseClient.UpdateDatabase(parsedDatabase); } /// diff --git a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoQueryUtils.cs b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoQueryUtils.cs index bfc2a201..63984df3 100644 --- a/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoQueryUtils.cs +++ b/src/Microsoft.Kusto.ServiceLayer/DataSource/KustoQueryUtils.cs @@ -111,5 +111,13 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource dictionary[key] = metadatas.OrderBy(x => x.PrettyName, StringComparer.OrdinalIgnoreCase).ToList(); } + public static string ParseDatabaseName(string databaseName) + { + var regex = new Regex(@"(?<=\().+?(?=\))"); + + return regex.IsMatch(databaseName) + ? regex.Match(databaseName).Value + : databaseName; + } } }