mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Default Kusto database name (#1187)
* Added check to set the databaseName to the first database on the cluster when no database is provided * Changed kusto query for loading databases to follow best practices * Fixed failing unit test * Optimized query for getting first database
This commit is contained in:
@@ -53,6 +53,15 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource
|
|||||||
var stringBuilder = GetKustoConnectionStringBuilder(connectionDetails);
|
var stringBuilder = GetKustoConnectionStringBuilder(connectionDetails);
|
||||||
_kustoQueryProvider = KustoClientFactory.CreateCslQueryProvider(stringBuilder);
|
_kustoQueryProvider = KustoClientFactory.CreateCslQueryProvider(stringBuilder);
|
||||||
_kustoAdminProvider = KustoClientFactory.CreateCslAdminProvider(stringBuilder);
|
_kustoAdminProvider = KustoClientFactory.CreateCslAdminProvider(stringBuilder);
|
||||||
|
|
||||||
|
if (DatabaseName != "NetDefaultDB")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataReader = ExecuteQuery(".show databases | top 1 by DatabaseName | project DatabaseName", new CancellationToken());
|
||||||
|
var databaseName = dataReader.ToEnumerable().Select(row => row["DatabaseName"]).FirstOrDefault();
|
||||||
|
DatabaseName = databaseName?.ToString() ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshAuthToken()
|
private void RefreshAuthToken()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
[Ignore("This should be moved to an integration test since Kusto Client calls Query")]
|
||||||
public void Constructor_Sets_ClusterName_With_DefaultDatabaseName()
|
public void Constructor_Sets_ClusterName_With_DefaultDatabaseName()
|
||||||
{
|
{
|
||||||
string clusterName = "https://fake.url.com";
|
string clusterName = "https://fake.url.com";
|
||||||
|
|||||||
Reference in New Issue
Block a user