atlasariga.io/atlas/sql/sqlcheck/datadepend Index | Files

package datadepend

import "ariga.io/atlas/sql/sqlcheck/datadepend"

Index

Functions

func ColumnFilled

func ColumnFilled(p *sqlcheck.Pass, t *schema.Table, c *schema.Column, pos int) bool

ColumnFilled checks if the column was filled with values before the given position.

func HasNotNullCheck

func HasNotNullCheck(p *sqlcheck.Pass, c *schema.Column) bool

HasNotNullCheck checks if the given column has a check constraint with a NOT NULL check. In case a CHECK exists, this reduces the risk for data-depend conflicts when changing a nullable column to non-nullable.

Types

type Analyzer

type Analyzer struct {
	sqlcheck.Options
	Handler
}

Analyzer checks data-dependent changes.

func New

func New(r *schemahcl.Resource, h Handler) (*Analyzer, error)

New creates a new data-dependent analyzer with the given options.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx context.Context, p *sqlcheck.Pass) error

Analyze runs data-depend analysis on MySQL changes.

func (*Analyzer) Diagnostics

func (a *Analyzer) Diagnostics(_ context.Context, p *sqlcheck.Pass) (diags []sqlcheck.Diagnostic)

Diagnostics runs the common analysis on the file and returns its diagnostics.

func (*Analyzer) Name

func (*Analyzer) Name() string

Name of the analyzer. Implements the sqlcheck.NamedAnalyzer interface.

func (*Analyzer) Report

func (a *Analyzer) Report(p *sqlcheck.Pass, diags []sqlcheck.Diagnostic) error

Report provides standard reporting for data-dependent changes. Drivers that decorate this Analyzer should call this function to get consistent reporting between dialects.

type ColumnHandler

type ColumnHandler func(*ColumnPass) ([]sqlcheck.Diagnostic, error)

ColumnHandler allows provide custom diagnostic for specific column rules.

type ColumnPass

type ColumnPass struct {
	*sqlcheck.Pass
	Change *sqlcheck.Change // Change context (statement).
	Table  *schema.Table    // The table this column belongs to.
	Column *schema.Column   // The diagnosed column.
}

ColumnPass wraps the information needed by the handler below to diagnose columns.

type Handler

type Handler struct {
	// AddNotNull is applied when a new non-nullable column was
	// added to an existing table.
	AddNotNull ColumnHandler

	// ModifyNotNull is an optional handler applied when
	// a nullable column was changed to non-nullable.
	ModifyNotNull ColumnHandler
}

Handler holds the underlying driver handlers.

Source Files

datadepend.go

Version
v0.32.0 (latest)
Published
Mar 10, 2025
Platform
linux/amd64
Imports
10 packages
Last checked
1 month ago

Tools for package owners.