Skip to content

Commit

Permalink
Merge pull request #606 from MarkMpn/ssms-21
Browse files Browse the repository at this point in the history
.NET 8
  • Loading branch information
MarkMpn authored Dec 5, 2024
2 parents ec46b5e + 9e65741 commit a6fde45
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 54 deletions.
22 changes: 22 additions & 0 deletions AzureDataStudioExtension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Change Log

## [v9.5.0](https://github.com/MarkMpn/Sql4Cds/releases/tag/v9.4.1) - 2024-12-07

Updated to .NET 8

Bulk DML improvements
* Automatically adjust batch size to keep requests within timeout limits
* Automatically adjust thread count to avoid hitting service protection limits
* Provide better feedback when queries pause due to service protection limits
* Automatically retry requests that have failed due to a transient error
* Added DML support for `solutioncomponent` table

Metadata improvements
* Expose optionset values via `metadata.globaloptionsetvalue` and `metadata.optionsetvalue` tables
* Reduced amount of metadata required to execute queries

Bug fixes
* Use correct scale when displaying numeric results
* Fixed "Must declare the scalar variable @Cond" error when using nested loop for single-record joins
* Do not trust `RetrieveTotalRecordCount` for certain metadata-related entities that give incorrect results
* Avoid errors when using cross-table column comparisons and nested link entities
* Handle nested primary functions

## [v9.4.1](https://github.com/MarkMpn/Sql4Cds/releases/tag/v9.4.1) - 2024-11-10

Fixed Intellisense with trailing comments
Expand Down
4 changes: 2 additions & 2 deletions MarkMpn.Sql4Cds.Engine/MarkMpn.Sql4Cds.Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<AssemblyName>MarkMpn.Sql4Cds.Engine</AssemblyName>
<RootNamespace>MarkMpn.Sql4Cds.Engine</RootNamespace>
<Copyright>Copyright © 2020 - 2024 Mark Carrington</Copyright>
Expand Down Expand Up @@ -30,7 +30,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.1.9" Condition=" '$(TargetFramework)' == 'net6.0' " />
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.2" Condition=" '$(TargetFramework)' == 'net8.0' " />
<PackageReference Include="Microsoft.CrmSdk.CoreAssemblies" Version="9.0.2.49" Condition=" '$(TargetFramework)' == 'net462' " />
<PackageReference Include="Microsoft.CrmSdk.XrmTooling.CoreAssembly" Version="9.1.1.32" Condition=" '$(TargetFramework)' == 'net462' " />
<PackageReference Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="161.8834.0" />
Expand Down
27 changes: 21 additions & 6 deletions MarkMpn.Sql4Cds.Engine/MarkMpn.Sql4Cds.Engine.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,24 @@
<iconUrl>https://markcarrington.dev/sql4cds-icon/</iconUrl>
<description>Convert SQL queries to FetchXml and execute them against Dataverse / D365</description>
<summary>Convert SQL queries to FetchXml and execute them against Dataverse / D365</summary>
<releaseNotes>Include join alias in output column aliases when converting from Fetch XML to SQL
Improved SQL to Fetch XML conversion of datetime filters
Fixed use of case-insensitive table names in INSERT statements
<releaseNotes>Updated to .NET 8

Bulk DML improvements
* Automatically adjust batch size to keep requests within timeout limits
* Automatically adjust thread count to avoid hitting service protection limits
* Provide better feedback when queries pause due to service protection limits
* Automatically retry requests that have failed due to a transient error
* Added DML support for `solutioncomponent` table

Metadata improvements
* Expose optionset values via `metadata.globaloptionsetvalue` and `metadata.optionsetvalue` tables
* Reduced amount of metadata required to execute queries

Bug fixes
* Fixed "Must declare the scalar variable @Cond" error when using nested loop for single-record joins
* Do not trust `RetrieveTotalRecordCount` for certain metadata-related entities that give incorrect results
* Avoid errors when using cross-table column comparisons and nested link entities
* Handle nested primary functions
</releaseNotes>
<copyright>Copyright © 2020 Mark Carrington</copyright>
<language>en-GB</language>
Expand All @@ -27,8 +42,8 @@ Fixed use of case-insensitive table names in INSERT statements
<dependency id="System.Data.SqlClient" version="4.8.6" />
<dependency id="XPath2.Extensions" version="1.1.3" />
</group>
<group targetFramework=".NETCoreApp6.0">
<dependency id="Microsoft.PowerPlatform.Dataverse.Client" version="1.1.9" />
<group targetFramework=".NETCoreApp8.0">
<dependency id="Microsoft.PowerPlatform.Dataverse.Client" version="1.2.2" />
<dependency id="Microsoft.SqlServer.TransactSql.ScriptDom" version="161.8834.0" />
<dependency id="Microsoft.ApplicationInsights" version="2.21.0" />
<dependency id="System.Data.SqlClient" version="4.8.6" />
Expand All @@ -39,7 +54,7 @@ Fixed use of case-insensitive table names in INSERT statements
</metadata>
<files>
<file src=".\bin\Release\net462\MarkMpn.Sql4Cds.Engine.dll" target="lib\net462\MarkMpn.Sql4Cds.Engine.dll" />
<file src=".\bin\Release\net6.0\MarkMpn.Sql4Cds.Engine.dll" target="lib\net6.0\MarkMpn.Sql4Cds.Engine.dll" />
<file src=".\bin\Release\net6.0\MarkMpn.Sql4Cds.Engine.dll" target="lib\net8.0\MarkMpn.Sql4Cds.Engine.dll" />
<file src="..\README.md" target="docs\" />
</files>
</package>
36 changes: 21 additions & 15 deletions MarkMpn.Sql4Cds.LanguageServer/Autocomplete/Autocomplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Reflection;
using System.Text;
using Data8.PowerPlatform.Dataverse.Client.Wsdl;
using MarkMpn.Sql4Cds.Engine;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.VisualStudio.LanguageServer.Protocol;
Expand Down Expand Up @@ -314,7 +313,7 @@ public IEnumerable<SqlAutocompleteItem> GetSuggestions(string text, int pos)
var availableParameters = message.InputParameters
.Concat(message.OutputParameters)
.OrderBy(p => p.Name)
.Select(p => new SprocParameterAutocompleteItem(message, p, currentLength));
.Select(p => new SprocParameterAutocompleteItem(message, p, instance, currentLength));

return FilterList(availableParameters, currentWord);
}
Expand Down Expand Up @@ -540,7 +539,7 @@ public IEnumerable<SqlAutocompleteItem> GetSuggestions(string text, int pos)
message.IsValidAsTableValuedFunction())
{
if (!Guid.TryParse(table.Key, out _))
items.Add(new TVFAutocompleteItem(message, table.Key, currentLength));
items.Add(new TVFAutocompleteItem(message, instance, table.Key, currentLength));

attributes.AddRange(GetMessageOutputAttributes(message, instance));
}
Expand Down Expand Up @@ -786,7 +785,7 @@ private IEnumerable<SqlAutocompleteItem> AutocompleteTableName(string currentWor

// Show TVF list
if (fromClause && ds.Metadata != null)
list.AddRange(ds.MessageCache.GetAllMessages().Where(x => x.IsValidAsTableValuedFunction()).Select(x => new TVFAutocompleteItem(x, _columnOrdering, currentLength)));
list.AddRange(ds.MessageCache.GetAllMessages().Where(x => x.IsValidAsTableValuedFunction()).Select(x => new TVFAutocompleteItem(x, _columnOrdering, ds, currentLength)));
}
}
else if (TryParseTableName(currentWord, out var instanceName, out var schemaName, out var tableName, out var parts, out var lastPartLength))
Expand Down Expand Up @@ -856,7 +855,7 @@ private IEnumerable<SqlAutocompleteItem> AutocompleteTableName(string currentWor
if (fromClause)
{
messages = messages.Where(e => e.IsValidAsTableValuedFunction() && e.Name.StartsWith(lastPart, StringComparison.OrdinalIgnoreCase));
list.AddRange(messages.Select(e => new TVFAutocompleteItem(e, _columnOrdering, lastPartLength)));
list.AddRange(messages.Select(e => new TVFAutocompleteItem(e, _columnOrdering, instance, lastPartLength)));
}
}
}
Expand All @@ -877,7 +876,7 @@ private IEnumerable<SqlAutocompleteItem> AutocompleteSprocName(string currentWor
list.AddRange(_dataSources.Values.Select(x => new InstanceAutocompleteItem(x, currentLength)));

if (_dataSources.TryGetValue(_primaryDataSource, out var ds) && ds.MessageCache != null)
list.AddRange(ds.MessageCache.GetAllMessages().Where(x => x.IsValidAsStoredProcedure()).Select(x => new SprocAutocompleteItem(x, _columnOrdering, currentLength)));
list.AddRange(ds.MessageCache.GetAllMessages().Where(x => x.IsValidAsStoredProcedure()).Select(x => new SprocAutocompleteItem(x, _columnOrdering, ds, currentLength)));
}
else if (TryParseTableName(currentWord, out var instanceName, out var schemaName, out var tableName, out var parts, out var lastPartLength))
{
Expand Down Expand Up @@ -905,7 +904,7 @@ private IEnumerable<SqlAutocompleteItem> AutocompleteSprocName(string currentWor

// Could be a sproc name
if (schemaName.Equals("dbo", StringComparison.OrdinalIgnoreCase) && instance?.MessageCache != null)
list.AddRange(instance.MessageCache.GetAllMessages().Where(x => x.IsValidAsStoredProcedure()).Select(e => new SprocAutocompleteItem(e, _columnOrdering, lastPartLength)));
list.AddRange(instance.MessageCache.GetAllMessages().Where(x => x.IsValidAsStoredProcedure()).Select(e => new SprocAutocompleteItem(e, _columnOrdering, instance, lastPartLength)));
}

list.Sort();
Expand Down Expand Up @@ -1552,16 +1551,19 @@ class TVFAutocompleteItem : SqlAutocompleteItem
{
private readonly Message _message;
private readonly ColumnOrdering _columnOrdering;
private readonly DataSource _dataSource;

public TVFAutocompleteItem(Message message, ColumnOrdering columnOrdering, int replaceLength) : base(message.Name, replaceLength, CompletionItemKind.Function)
public TVFAutocompleteItem(Message message, ColumnOrdering columnOrdering, DataSource dataSource, int replaceLength) : base(message.Name, replaceLength, CompletionItemKind.Function)
{
_message = message;
_columnOrdering = columnOrdering;
_dataSource = dataSource;
}

public TVFAutocompleteItem(Message message, string alias, int replaceLength) : base(alias, replaceLength, CompletionItemKind.Function)
public TVFAutocompleteItem(Message message, DataSource dataSource, string alias, int replaceLength) : base(alias, replaceLength, CompletionItemKind.Function)
{
_message = message;
_dataSource = dataSource;
}

public override string ToolTipTitle
Expand All @@ -1582,7 +1584,7 @@ public override string ToolTipText
else
parameters = parameters.OrderBy(p => p.Position);

return _message.Name + "(" + String.Join(", ", parameters.Select(p => p.Name + " " + p.GetSqlDataType(null).ToSql())) + ")";
return _message.Name + "(" + String.Join(", ", parameters.Select(p => p.Name + " " + p.GetSqlDataType(_dataSource).ToSql())) + ")";
}
set => base.ToolTipText = value;
}
Expand All @@ -1597,11 +1599,13 @@ class SprocAutocompleteItem : SqlAutocompleteItem
{
private readonly Message _message;
private readonly ColumnOrdering _columnOrdering;
private readonly DataSource _dataSource;

public SprocAutocompleteItem(Message message, ColumnOrdering columnOrdering, int replaceLength) : base(message.Name, replaceLength, CompletionItemKind.Method)
public SprocAutocompleteItem(Message message, ColumnOrdering columnOrdering, DataSource dataSource, int replaceLength) : base(message.Name, replaceLength, CompletionItemKind.Method)
{
_message = message;
_columnOrdering = columnOrdering;
_dataSource = dataSource;
}

public override string ToolTipTitle
Expand All @@ -1622,7 +1626,7 @@ public override string ToolTipText
else
parameters = parameters.OrderBy(p => p.Position);

return _message.Name + " " + String.Join(", ", parameters.Select(p => (p.Optional ? "[" : "") + "@" + p.Name + " = " + p.GetSqlDataType(null).ToSql() + (p.Optional ? "]" : ""))) + (_message.OutputParameters.Count == 0 ? "" : ((_message.InputParameters.Count == 0 ? "" : ",") + " " + String.Join(", ", _message.OutputParameters.Select(p => "[@" + p.Name + " = " + p.GetSqlDataType(null).ToSql() + " OUTPUT]"))));
return _message.Name + " " + String.Join(", ", parameters.Select(p => (p.Optional ? "[" : "") + "@" + p.Name + " = " + p.GetSqlDataType(_dataSource).ToSql() + (p.Optional ? "]" : ""))) + (_message.OutputParameters.Count == 0 ? "" : ((_message.InputParameters.Count == 0 ? "" : ",") + " " + String.Join(", ", _message.OutputParameters.Select(p => "[@" + p.Name + " = " + p.GetSqlDataType(_dataSource).ToSql() + " OUTPUT]"))));
}
set => base.ToolTipText = value;
}
Expand All @@ -1632,22 +1636,24 @@ class SprocParameterAutocompleteItem : SqlAutocompleteItem
{
private readonly Message _message;
private readonly MessageParameter _parameter;
private readonly DataSource _dataSource;

public SprocParameterAutocompleteItem(Message message, MessageParameter parameter, int replaceLength) : base("@" + parameter.Name, replaceLength, CompletionItemKind.Variable)
public SprocParameterAutocompleteItem(Message message, MessageParameter parameter, DataSource dataSource, int replaceLength) : base("@" + parameter.Name, replaceLength, CompletionItemKind.Variable)
{
_message = message;
_parameter = parameter;
_dataSource = dataSource;
}

public override string ToolTipTitle
{
get => _parameter.Name + (_message.OutputParameters.Contains(_parameter) ? " output" : " input") + " parameter (" + _parameter.GetSqlDataType(null).ToSql() + ")";
get => _parameter.Name + (_message.OutputParameters.Contains(_parameter) ? " output" : " input") + " parameter (" + _parameter.GetSqlDataType(_dataSource).ToSql() + ")";
set => base.ToolTipTitle = value;
}

public override string ToolTipText
{
get => _message.Name + " " + string.Join(", ", _message.InputParameters.Select(p => (p.Optional ? "[" : "") + "@" + p.Name + " = " + p.GetSqlDataType(null).ToSql() + (p.Optional ? "]" : ""))) + (_message.OutputParameters.Count == 0 ? "" : (_message.InputParameters.Count == 0 ? "" : ",") + " " + string.Join(", ", _message.OutputParameters.Select(p => "[@" + p.Name + " = " + p.GetSqlDataType(null).ToSql() + " OUTPUT]")));
get => _message.Name + " " + string.Join(", ", _message.InputParameters.Select(p => (p.Optional ? "[" : "") + "@" + p.Name + " = " + p.GetSqlDataType(_dataSource).ToSql() + (p.Optional ? "]" : ""))) + (_message.OutputParameters.Count == 0 ? "" : (_message.InputParameters.Count == 0 ? "" : ",") + " " + string.Join(", ", _message.OutputParameters.Select(p => "[@" + p.Name + " = " + p.GetSqlDataType(_dataSource).ToSql() + " OUTPUT]")));
set => base.ToolTipText = value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Copyright>Copyright © 2022 - 2024 Mark Carrington</Copyright>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Data8.PowerPlatform.Dataverse.Client" Version="2.3.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.1.9" />
<PackageReference Include="Data8.PowerPlatform.Dataverse.Client" Version="2.4.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.PowerPlatform.Dataverse.Client" Version="1.2.2" />
<PackageReference Include="Microsoft.VisualStudio.LanguageServer.Protocol" Version="17.2.8" />
<PackageReference Include="StreamJsonRpc" Version="2.14.24" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.34.0" />
<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private async Task ExecuteAsync(Connection.Session session, ExecuteRequestParams
var schemaTable = reader.GetSchemaTable();

for (var i = 0; i < reader.FieldCount; i++)
resultSet.ColumnInfo[i] = new DbColumnWrapper((string)schemaTable.Rows[i]["ColumnName"], (string)schemaTable.Rows[i]["DataTypeName"], (short?)schemaTable.Rows[i]["NumericScale"]);
resultSet.ColumnInfo[i] = new DbColumnWrapper(schemaTable.Rows[i]["ColumnName"] as string, (string)schemaTable.Rows[i]["DataTypeName"], (short?)schemaTable.Rows[i]["NumericScale"]);

resultSetInProgress = resultSet;
resultSets.Add(resultSet);
Expand Down
Loading

0 comments on commit a6fde45

Please sign in to comment.