19 lines
577 B
C#
19 lines
577 B
C#
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
|
using SQLLinter.Common;
|
|
|
|
namespace SQLLinter.Infrastructure.Rules;
|
|
|
|
public class DistinctRule : BaseRuleVisitor
|
|
{
|
|
public override string Text => "Избегать DISTINCT, отдавать предпочтение GROUP BY.";
|
|
|
|
public override void Visit(SelectStatement node)
|
|
{
|
|
var query = node.QueryExpression as QuerySpecification;
|
|
if (query != null && query.SelectElements.Any() && query.UniqueRowFilter == UniqueRowFilter.Distinct)
|
|
{
|
|
AddViolation(node);
|
|
}
|
|
}
|
|
}
|