Documentation
¶
Overview ¶
Package naming provides linter rules for SQL naming conventions and style.
Rules:
- L024: Table alias required (multi-table queries)
- L025: Reserved keyword used as identifier
- L026: Implicit column list in INSERT
- L027: UNION instead of UNION ALL
- L028: Missing ORDER BY with LIMIT
- L029: Subquery in WHERE can be a JOIN
- L030: DISTINCT on many columns
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DistinctOnManyColumnsRule ¶
DistinctOnManyColumnsRule (L030) warns when DISTINCT is used with many columns. DISTINCT on many columns is often a sign of a missing GROUP BY or denormalized data. It also forces a sort over all projected columns, which is expensive.
func NewDistinctOnManyColumnsRule ¶
func NewDistinctOnManyColumnsRule() *DistinctOnManyColumnsRule
NewDistinctOnManyColumnsRule creates a new L030 rule instance.
type ImplicitColumnListRule ¶
ImplicitColumnListRule (L026) flags INSERT statements without an explicit column list. INSERT INTO table VALUES (...) is fragile — it breaks when columns are added/reordered.
func NewImplicitColumnListRule ¶
func NewImplicitColumnListRule() *ImplicitColumnListRule
NewImplicitColumnListRule creates a new L026 rule instance.
type MissingOrderByLimitRule ¶
MissingOrderByLimitRule (L028) flags queries that use LIMIT/OFFSET without ORDER BY. Without ORDER BY, the rows returned by LIMIT are non-deterministic — different executions may return different rows, making pagination unreliable.
func NewMissingOrderByLimitRule ¶
func NewMissingOrderByLimitRule() *MissingOrderByLimitRule
NewMissingOrderByLimitRule creates a new L028 rule instance.
type ReservedKeywordIdentifierRule ¶
ReservedKeywordIdentifierRule (L025) flags table names or aliases that match SQL reserved keywords (without quoting). Using reserved words as identifiers requires quoting and is confusing for both humans and some SQL parsers.
func NewReservedKeywordIdentifierRule ¶
func NewReservedKeywordIdentifierRule() *ReservedKeywordIdentifierRule
NewReservedKeywordIdentifierRule creates a new L025 rule instance.
type SubqueryCanBeJoinRule ¶
SubqueryCanBeJoinRule (L029) flags correlated EXISTS/IN subqueries in WHERE clauses that could be expressed more efficiently as a JOIN. EXISTS (SELECT ...) and IN (SELECT ...) can often be replaced with a JOIN or LEFT JOIN ... IS NULL for better performance and readability.
func NewSubqueryCanBeJoinRule ¶
func NewSubqueryCanBeJoinRule() *SubqueryCanBeJoinRule
NewSubqueryCanBeJoinRule creates a new L029 rule instance.
type TableAliasRequiredRule ¶
TableAliasRequiredRule (L024) flags multi-table queries where any table has no alias. Unaliased tables in multi-table queries make column references ambiguous and harder to read.
func NewTableAliasRequiredRule ¶
func NewTableAliasRequiredRule() *TableAliasRequiredRule
NewTableAliasRequiredRule creates a new L024 rule instance.
type UnionAllPreferredRule ¶
UnionAllPreferredRule (L027) flags UNION (deduplicating) when the caller likely meant UNION ALL. UNION performs a sort+dedup pass which is significantly more expensive than UNION ALL. If duplicates are intentionally removed, this is fine, but it should be an explicit choice.
func NewUnionAllPreferredRule ¶
func NewUnionAllPreferredRule() *UnionAllPreferredRule
NewUnionAllPreferredRule creates a new L027 rule instance.