-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended validation of GROUP BY and EXECUTE AS expressions
- Loading branch information
Showing
6 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
MarkMpn.Sql4Cds.Engine/Visitors/GroupByValidatingVisitor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.SqlServer.TransactSql.ScriptDom; | ||
|
||
namespace MarkMpn.Sql4Cds.Engine.Visitors | ||
{ | ||
class GroupByValidatingVisitor : TSqlFragmentVisitor | ||
{ | ||
public Sql4CdsError Error { get; private set; } | ||
|
||
public override void Visit(GroupByClause node) | ||
{ | ||
if (node.All == true) | ||
Error = Sql4CdsError.NotSupported(node, "GROUP BY ALL"); | ||
|
||
if (node.GroupByOption != GroupByOption.None) | ||
Error = Sql4CdsError.NotSupported(node, $"GROUP BY {node.GroupByOption}"); | ||
} | ||
|
||
public override void Visit(ScalarSubquery node) | ||
{ | ||
Error = Sql4CdsError.InvalidAggregateOrSubqueryInGroupByClause(node); | ||
} | ||
|
||
public override void Visit(FunctionCall node) | ||
{ | ||
if (AggregateCollectingVisitor.IsAggregate(node)) | ||
Error = Sql4CdsError.InvalidAggregateOrSubqueryInGroupByClause(node); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters