18 lines
533 B
C#
18 lines
533 B
C#
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
|
using SQLLinter.Common;
|
|
|
|
namespace SQLLinter.Infrastructure.Rules;
|
|
|
|
public class TopWithoutOrderByRule : BaseRuleVisitor
|
|
{
|
|
public override string Text => "TOP без ORDER BY может дать непредсказуемый результат";
|
|
|
|
public override void Visit(QuerySpecification node)
|
|
{
|
|
if (node.TopRowFilter != null && node.OrderByClause == null)
|
|
{
|
|
AddViolation(node.TopRowFilter);
|
|
}
|
|
base.Visit(node);
|
|
}
|
|
} |