Skip to content

Commit

Permalink
Merge pull request #467 from MarkMpn/v9-fixes
Browse files Browse the repository at this point in the history
V9 fixes
  • Loading branch information
MarkMpn authored May 8, 2024
2 parents dc5ad56 + 63b467a commit d2b3862
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 48 deletions.
16 changes: 15 additions & 1 deletion AzureDataStudioExtension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Change Log

## [v9.0.0](https://github.com/MarkMpn/Sql4Cds/releases/tag/v8.0.1) - 2024-05-02
## [v9.0.1](https://github.com/MarkMpn/Sql4Cds/releases/tag/v9.0.1) - 2024-05-08

Fixed `NullReferenceException` errors when:
- executing a conditional `SELECT` query
- retrieving results from a Fetch XML query using `IN` or `EXISTS`
- handling an error returned from TDS Endpoint
- handling internal errors such as `UPDATE` without `WHERE`

Standardised errors on:
- JSON path errors
- DML statement cancellation

Fixed filtering `audit` data on `changedata` attribute

## [v9.0.0](https://github.com/MarkMpn/Sql4Cds/releases/tag/v9.0.0) - 2024-05-02

Added support for latest Fetch XML features
Support `TRY`, `CATCH` & `THROW` statements and related functions
Expand Down
19 changes: 13 additions & 6 deletions MarkMpn.Sql4Cds.Engine/ExecutionPlan/BaseDataNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc

var entityName = AliasToEntityName(targetEntityAlias, targetEntityName, items, entityAlias);

if (IsInvalidAuditFilter(targetEntityName, entityName, items))
if (IsInvalidAuditFilter(targetEntityName, entityName, items, attrName))
return false;

var meta = dataSource.Metadata[entityName];
Expand Down Expand Up @@ -668,7 +668,7 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc

var entityName = AliasToEntityName(targetEntityAlias, targetEntityName, items, entityAlias);

if (IsInvalidAuditFilter(targetEntityName, entityName, items))
if (IsInvalidAuditFilter(targetEntityName, entityName, items, attrName))
return false;

var meta = dataSource.Metadata[entityName];
Expand All @@ -695,7 +695,7 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc

var entityName = AliasToEntityName(targetEntityAlias, targetEntityName, items, entityAlias);

if (IsInvalidAuditFilter(targetEntityName, entityName, items))
if (IsInvalidAuditFilter(targetEntityName, entityName, items, attrName))
return false;

var meta = dataSource.Metadata[entityName];
Expand Down Expand Up @@ -728,7 +728,7 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc

var entityName = AliasToEntityName(targetEntityAlias, targetEntityName, items, entityAlias);

if (IsInvalidAuditFilter(targetEntityName, entityName, items))
if (IsInvalidAuditFilter(targetEntityName, entityName, items, attrName))
return false;

var meta = dataSource.Metadata[entityName];
Expand Down Expand Up @@ -775,7 +775,7 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc

var entityName = AliasToEntityName(targetEntityAlias, targetEntityName, items, entityAlias);

if (IsInvalidAuditFilter(targetEntityName, entityName, items))
if (IsInvalidAuditFilter(targetEntityName, entityName, items, attrName))
return false;

var meta = dataSource.Metadata[entityName];
Expand All @@ -797,18 +797,25 @@ private bool TranslateFetchXMLCriteria(NodeCompilationContext context, DataSourc
/// <param name="targetEntityName">The base entity type of the FetchXML query</param>
/// <param name="entityName">The entity type being filtered</param>
/// <param name="items">The list of items in the FetchXML entity element</param>
/// <param name="attrName">The name of the attribute the filter will be applied on</param>
/// <returns><c>true</c> if the filter cannot be applied, or <c>false</c> otherwise</returns>
/// <remarks>
/// The audit provider does not support filtering using the &lt;condition entityname="systemuser" .../&gt; syntax.
/// See https://github.com/MarkMpn/Sql4Cds/issues/294
/// </remarks>
private bool IsInvalidAuditFilter(string targetEntityName, string entityName, object[] items)
private bool IsInvalidAuditFilter(string targetEntityName, string entityName, object[] items, string attrName)
{
if (targetEntityName != "audit")
return false;

if (entityName == "audit")
{
// Can't filter on the changedata attribute
if (attrName == "changedata")
return true;

return false;
}

// Audit can only have a single join.
var join = items.OfType<FetchLinkEntityType>().Single();
Expand Down
30 changes: 11 additions & 19 deletions MarkMpn.Sql4Cds.Engine/MarkMpn.Sql4Cds.Engine.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,17 @@
<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>Added support for latest Fetch XML features
Support TRY, CATCH &amp; THROW statements and related functions
Error handling consistency with SQL Server
Improved performance with large numbers of expressions and large VALUES lists
Generate the execution plan for each statement in a batch only when necessary, to allow initial statements to succeed regardless of errors in later statements
Allow access to catalog views using TDS Endpoint
Inproved EXECUTE AS support
Handle missing values in XML .value() method
Detect TDS Endpoint incompatibility with XML data type methods and error handling functions
Fixed use of TOP 1 with IN expression
Fixed escaping column names for SELECT and INSERT commands
Improved setting a partylist attribute based on an EntityReference value
Fixed sorting results for UNION
Fold DISTINCT to data source for UNION
Fold groupings without aggregates to DISTINCT
Fixed folding filters through nested loops with outer references
Fixed use of recursive CTE references within subquery
Improved performance of CROSS APPLY and OUTER APPLY
Improved query cancellation
<releaseNotes>Fixed NullReferenceException errors when:
- executing a conditional SELECT query
- retrieving results from a Fetch XML query using IN or EXISTS
- handling an error returned from TDS Endpoint
- handling internal errors such as UPDATE without WHERE

Standardised errors on:
- JSON path errors
- DML statement cancellation

Fixed filtering audit data on changedata attribute
</releaseNotes>
<copyright>Copyright © 2020 Mark Carrington</copyright>
<language>en-GB</language>
Expand Down
32 changes: 10 additions & 22 deletions MarkMpn.Sql4Cds/MarkMpn.SQL4CDS.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,17 @@ plugins or integrations by writing familiar SQL and converting it.
Queries can also run using the preview TDS Endpoint. A wide range of SQL functionality is also built
in to allow running queries that aren't directly supported by either FetchXML or the TDS Endpoint.</description>
<summary>Convert SQL queries to FetchXML and execute them against Dataverse / D365</summary>
<releaseNotes>Added support for latest Fetch XML features
Support TRY, CATCH &amp; THROW statements and related functions
Error handling consistency with SQL Server
Improved performance with large numbers of expressions and large VALUES lists
Generate the execution plan for each statement in a batch only when necessary, to allow initial statements to succeed regardless of errors in later statements
Allow access to catalog views using TDS Endpoint
Inproved EXECUTE AS support
Handle missing values in XML .value() method
Detect TDS Endpoint incompatibility with XML data type methods and error handling functions
Fixed use of TOP 1 with IN expression
Fixed escaping column names for SELECT and INSERT commands
Improved setting a partylist attribute based on an EntityReference value
Fixed sorting results for UNION
Fold DISTINCT to data source for UNION
Fold groupings without aggregates to DISTINCT
Fixed folding filters through nested loops with outer references
Fixed use of recursive CTE references within subquery
Improved performance of CROSS APPLY and OUTER APPLY
Improved query cancellation
<releaseNotes>Fixed NullReferenceException errors when:
- executing a conditional SELECT query
- retrieving results from a Fetch XML query using IN or EXISTS
- handling an error returned from TDS Endpoint
- handling internal errors such as UPDATE without WHERE

Fixed opening the tool without a connection
Improved copying results from grid
Fixed formatting queries with trailing comments
Standardised errors on:
- JSON path errors
- DML statement cancellation

Fixed filtering audit data on changedata attribute
</releaseNotes>
<copyright>Copyright © 2019 Mark Carrington</copyright>
<language>en-GB</language>
Expand Down

0 comments on commit d2b3862

Please sign in to comment.