Добавьте файлы проекта.
This commit is contained in:
20
SQLLinter/Infrastructure/Rules/ExcessiveJoinsRule.cs
Normal file
20
SQLLinter/Infrastructure/Rules/ExcessiveJoinsRule.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
||||
using SQLLinter.Common;
|
||||
|
||||
namespace SQLLinter.Infrastructure.Rules;
|
||||
|
||||
public class ExcessiveJoinsRule : BaseRuleVisitor
|
||||
{
|
||||
public override string Text => "Слишком много таблиц в запросе (>" + _maxJoins + "): {0}";
|
||||
|
||||
private const int _maxJoins = 10;
|
||||
|
||||
public override void Visit(QuerySpecification node)
|
||||
{
|
||||
if (node.FromClause != null && node.FromClause.TableReferences.Count > _maxJoins)
|
||||
{
|
||||
AddViolation(node.FromClause, $"Количество таблиц: {node.FromClause.TableReferences.Count}");
|
||||
}
|
||||
base.Visit(node);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user