Skip to content

Commit

Permalink
Revert "Update Kusto dependencies to create correct symbol"
Browse files Browse the repository at this point in the history
This reverts commit 71ab1be.
  • Loading branch information
ludwhe committed Jun 16, 2023
1 parent 71ab1be commit 71251d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Update="Microsoft.SqlServer.DacFx" Version="162.0.15-preview" />
<PackageReference Update="Microsoft.SqlServer.DacFx.Projects" Version="162.0.28-alpha" />
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="9.0.4" />
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="11.3.0" />
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="9.0.4" />
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.1.17]" />
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20230301.46" />
<PackageReference Update="Microsoft.SqlServer.Migration.Logins" Version="1.0.20230407.56" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private GlobalState LoadSchemaState(string databaseName, string clusterName)
{
IEnumerable<ShowDatabaseSchemaResult> tableSchemas = Enumerable.Empty<ShowDatabaseSchemaResult>();
IEnumerable<ShowFunctionsResult> functionSchemas = Enumerable.Empty<ShowFunctionsResult>();
var materializedViewSchemasAndQueries = new ConcurrentBag<(ShowMaterializedViewSchemaResult Schema, string Query)>();
var materializedViewSchemas = new ConcurrentBag<ShowMaterializedViewSchemaResult>();

if (!string.IsNullOrWhiteSpace(databaseName))
{
Expand All @@ -62,29 +62,29 @@ private GlobalState LoadSchemaState(string databaseName, string clusterName)

if (materializedViewSchema != null)
{
materializedViewSchemasAndQueries.Add((materializedViewSchema, materializedView.Query));
materializedViewSchemas.Add(materializedViewSchema);
}
});
});
}

return AddOrUpdateDatabase(tableSchemas, functionSchemas, materializedViewSchemasAndQueries, GlobalState.Default, databaseName,
return AddOrUpdateDatabase(tableSchemas, functionSchemas, materializedViewSchemas, GlobalState.Default, databaseName,
clusterName);
}

/// <summary>
/// Loads the schema for the specified database and returns a new <see cref="GlobalState"/> with the database added or updated.
/// </summary>
private GlobalState AddOrUpdateDatabase(IEnumerable<ShowDatabaseSchemaResult> tableSchemas,
IEnumerable<ShowFunctionsResult> functionSchemas, IEnumerable<(ShowMaterializedViewSchemaResult Schema, string Query)> materializedViewSchemasAndQueries,
IEnumerable<ShowFunctionsResult> functionSchemas, IEnumerable<ShowMaterializedViewSchemaResult> materializedViewSchemas,
GlobalState globals, string databaseName, string clusterName)
{
// try and show error from here.
DatabaseSymbol databaseSymbol = null;

if (databaseName != null)
{
databaseSymbol = LoadDatabase(tableSchemas, functionSchemas, materializedViewSchemasAndQueries, databaseName);
databaseSymbol = LoadDatabase(tableSchemas, functionSchemas, materializedViewSchemas, databaseName);
}

if (databaseSymbol == null)
Expand All @@ -96,12 +96,12 @@ private GlobalState AddOrUpdateDatabase(IEnumerable<ShowDatabaseSchemaResult> ta
if (cluster == null)
{
cluster = new ClusterSymbol(clusterName, new[] { databaseSymbol }, isOpen: true);
globals = globals.AddOrReplaceCluster(cluster);
globals = globals.AddOrUpdateCluster(cluster);
}
else
{
cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
globals = globals.AddOrReplaceCluster(cluster);
globals = globals.AddOrUpdateCluster(cluster);
}

return globals.WithCluster(cluster).WithDatabase(databaseSymbol);
Expand All @@ -111,7 +111,7 @@ private GlobalState AddOrUpdateDatabase(IEnumerable<ShowDatabaseSchemaResult> ta
/// Loads the schema for the specified database into a <see cref="DatabaseSymbol"/>.
/// </summary>
private DatabaseSymbol LoadDatabase(IEnumerable<ShowDatabaseSchemaResult> tableSchemas,
IEnumerable<ShowFunctionsResult> functionSchemas, IEnumerable<(ShowMaterializedViewSchemaResult Schema, string Query)> materializedViewSchemasAndQueries,
IEnumerable<ShowFunctionsResult> functionSchemas, IEnumerable<ShowMaterializedViewSchemaResult> materializedViewSchemas,
string databaseName)
{
if (tableSchemas == null)
Expand Down Expand Up @@ -141,17 +141,17 @@ private DatabaseSymbol LoadDatabase(IEnumerable<ShowDatabaseSchemaResult> tableS
}
}

if (materializedViewSchemasAndQueries != null)
if (materializedViewSchemas != null)
{
foreach ((ShowMaterializedViewSchemaResult schema, string query) in materializedViewSchemasAndQueries)
foreach (var view in materializedViewSchemas)
{
var columns = schema.Schema.Split(',')
var columns = view.Schema.Split(',')
.Select(col =>
{
var nameType = col.Split(':');
return new ColumnSymbol(nameType[0], ScalarTypes.GetSymbol(nameType[1]));
});
var viewSymbol = new MaterializedViewSymbol(schema.TableName, columns, query);
var viewSymbol = new TableSymbol(view.TableName, columns);
members.Add(viewSymbol);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void GetAutoCompleteSuggestions_Returns_CompletionItems()
var documentInfo = new ScriptDocumentInfo(textDocumentPosition, scriptFile, scriptParseInfo);
var items = client.GetAutoCompleteSuggestions(documentInfo, position);

Assert.AreEqual(23, items.Length);
Assert.AreEqual(20, items.Length);
}
[Test]
public void UpdateDatabase_Updates_SchemaState()
Expand Down Expand Up @@ -169,7 +169,7 @@ public void UpdateDatabase_Updates_SchemaState()
var documentInfo = new ScriptDocumentInfo(textDocumentPosition, scriptFile, scriptParseInfo);
var items = client.GetAutoCompleteSuggestions(documentInfo, position);

Assert.AreEqual(22, items.Length);
Assert.AreEqual(19, items.Length);
var tableItem = items.FirstOrDefault(x => x.Detail == "Table");

// assert new table is being returned to show database has changed
Expand Down

0 comments on commit 71251d9

Please sign in to comment.