Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlcbinding

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package sqlcbinding discovers repository-owned sqlc v2 configuration and validates generated Go query methods against canonical handwritten SQL.

Index

Constants

View Source
const (
	AdapterVersion = "2"
)

Variables

This section is empty.

Functions

func IsBindingInput

func IsBindingInput(filePath string) bool

func IsConfigPath

func IsConfigPath(filePath string) bool

func IsSemanticInput

func IsSemanticInput(filePath string) bool

func ResolveTableArgument

func ResolveTableArgument(argument, statement string, tables []string, dialect string) (string, bool)

ResolveTableArgument maps a table name or statement alias to one unique parser-normalized table without guessing across alias/name collisions.

Types

type Binding

type Binding struct {
	Method           string
	GeneratedPath    string
	Constant         string
	Generator        string
	GeneratorVersion string
	ConfigPath       string
	Entry            int
	Location         graph.Location
}

type Config

type Config struct {
	Path        string
	Entries     []Entry
	Diagnostics []graph.Diagnostic
}

type Entry

type Entry struct {
	ConfigPath  string
	Index       int
	Engine      string
	SchemaPaths []string
	QueryPaths  []string
	SchemaRoots []string
	QueryRoots  []string
	Go          GoConfig
	Valid       bool
}

type GoConfig

type GoConfig struct {
	Package             string
	Out                 string
	EmitPreparedQueries bool
	EmitExportedQueries bool
}

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader() *Loader

func (*Loader) AffectedPaths

func (l *Loader) AffectedPaths(root string, changedPaths []string) (queries, configs []string, known bool)

AffectedPaths derives the exact config and query files whose binding evidence can change after changedPaths. It consults only a registry already published for root by WorkspaceSemanticKey; callers use the false result as unknown and may fall back conservatively.

func (*Loader) FileSemanticKey

func (l *Loader) FileSemanticKey(ctx context.Context, input parserapi.Input) (string, error)

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, input parserapi.Input) (Registry, error)

func (*Loader) SemanticKey

func (l *Loader) SemanticKey(ctx context.Context, input parserapi.Input) (string, error)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser owns diagnostics on sqlc configuration files. The SQL router and this parser share a Loader in the production registry, so configuration is parsed once per immutable indexing snapshot.

func New

func New(loader *Loader) *Parser

func (*Parser) IsSemanticInput

func (*Parser) IsSemanticInput(path string) bool

func (*Parser) Language

func (*Parser) Language() string

func (*Parser) Parse

func (p *Parser) Parse(ctx context.Context, input parserapi.Input) (graph.ParseResult, error)

func (*Parser) SemanticAffectedPaths

func (p *Parser) SemanticAffectedPaths(root string, allPaths, changedPaths []string) []string

func (*Parser) SemanticKey

func (p *Parser) SemanticKey(ctx context.Context, input parserapi.Input) (string, error)

func (*Parser) Supports

func (*Parser) Supports(path string) bool

func (*Parser) WorkspaceSemanticEvidenceKey

func (*Parser) WorkspaceSemanticEvidenceKey(context.Context, parserapi.Input) (string, error)

func (*Parser) WorkspaceSemanticKey

func (p *Parser) WorkspaceSemanticKey(ctx context.Context, input parserapi.Input) (string, error)

type Query

type Query struct {
	Path           string
	Name           string
	Command        string
	StatementStart int
	StatementEnd   int
	SQL            string
	Engine         string
	ConfigPath     string
	Entry          int
}

type Registry

type Registry struct {
	Digest string
	// contains filtered or unexported fields
}

func (Registry) BindingsForQuery

func (r Registry) BindingsForQuery(path, name string) []Binding

func (Registry) ColumnsForQuery

func (r Registry) ColumnsForQuery(queryPath, table string) ([]string, bool)

ColumnsForQuery returns complete, unique configured schema evidence for a table in the binding scopes that own queryPath. Compatible overlapping entries may agree; missing, conflicting, or ambiguous declarations fail closed.

func (Registry) Config

func (r Registry) Config(path string) (Config, bool)

func (Registry) Configs

func (r Registry) Configs() []Config

func (Registry) EntriesForQuery

func (r Registry) EntriesForQuery(path string) []Entry

func (Registry) EntriesForSQLPath

func (r Registry) EntriesForSQLPath(path string) []Entry

func (Registry) Query

func (r Registry) Query(path, name string) (Query, bool)

func (Registry) SchemaColumnsForQuery

func (r Registry) SchemaColumnsForQuery(queryPath, table string) (string, []string, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL