Добавьте файлы проекта.
This commit is contained in:
38
SQLLinter/Infrastructure/Rules/DataCompressionOptionRule.cs
Normal file
38
SQLLinter/Infrastructure/Rules/DataCompressionOptionRule.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
||||
using SQLLinter.Common;
|
||||
using SQLLinter.Common.Helpers;
|
||||
|
||||
namespace SQLLinter.Infrastructure.Rules;
|
||||
|
||||
public class DataCompressionOptionRule : BaseRuleVisitor
|
||||
{
|
||||
|
||||
public override string Text => "Объявление таблицы без использования сжатия данных: {0}";
|
||||
|
||||
public override void Visit(CreateTableStatement node)
|
||||
{
|
||||
if (node.SchemaObjectName.BaseIdentifier.Value.StartsWith("#")) return;
|
||||
|
||||
var childCompressionVisitor = new ChildCompressionVisitor();
|
||||
node.AcceptChildren(childCompressionVisitor);
|
||||
|
||||
if (!childCompressionVisitor.CompressionOptionExists)
|
||||
{
|
||||
AddViolation(node, SQLHelpers.ObjectGetFullName(node.SchemaObjectName));
|
||||
}
|
||||
}
|
||||
|
||||
private class ChildCompressionVisitor : TSqlFragmentVisitor
|
||||
{
|
||||
public bool CompressionOptionExists
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public override void Visit(DataCompressionOption node)
|
||||
{
|
||||
CompressionOptionExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user