Добавьте файлы проекта.
This commit is contained in:
34
SQLLinter/Infrastructure/Rules/TempTableModificationRule.cs
Normal file
34
SQLLinter/Infrastructure/Rules/TempTableModificationRule.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
||||
using SQLLinter.Common;
|
||||
using SQLLinter.Common.Helpers;
|
||||
|
||||
namespace SQLLinter.Infrastructure.Rules;
|
||||
|
||||
public class TempTableModificationRule : BaseRuleVisitor
|
||||
{
|
||||
public override string Text => "Избегать ALTER/UPDATE/DELETE для временных таблиц: {0}";
|
||||
|
||||
public override void Visit(UpdateStatement node)
|
||||
{
|
||||
if (node.UpdateSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#"))
|
||||
{
|
||||
AddViolation(node, SQLHelpers.ObjectGetFullName(tbl.SchemaObject));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Visit(DeleteStatement node)
|
||||
{
|
||||
if (node.DeleteSpecification.Target is NamedTableReference tbl && tbl.SchemaObject.BaseIdentifier.Value.StartsWith("#"))
|
||||
{
|
||||
AddViolation(node, SQLHelpers.ObjectGetFullName(tbl.SchemaObject));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Visit(AlterTableStatement node)
|
||||
{
|
||||
if (node.SchemaObjectName.BaseIdentifier.Value.StartsWith("#"))
|
||||
{
|
||||
AddViolation(node, SQLHelpers.ObjectGetFullName(node.SchemaObjectName));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user