Добавьте файлы проекта.
This commit is contained in:
25
SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs
Normal file
25
SQLLinter/Infrastructure/Rules/DeleteWhereRule.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
||||
using SQLLinter.Common;
|
||||
|
||||
namespace SQLLinter.Infrastructure.Rules;
|
||||
|
||||
public class DeleteWhereRule : BaseRuleVisitor, IRule
|
||||
{
|
||||
public override string Text => "Ожидается предложение WHERE для оператора DELETE: {0}";
|
||||
|
||||
public override void Visit(DeleteSpecification node)
|
||||
{
|
||||
if (node.WhereClause != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string name = string.Join("", node.Target.ScriptTokenStream
|
||||
.Skip(node.Target.FirstTokenIndex)
|
||||
.Take(node.Target.LastTokenIndex - node.Target.FirstTokenIndex + 1)
|
||||
.Select(t => t.Text)
|
||||
);
|
||||
|
||||
AddViolation(node, name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user