mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 17:24:14 -05:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user