analyzer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package analyzer validates and resolves SQL queries against a schema catalog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SQLiteTypeToGo

func SQLiteTypeToGo(sqliteType string) string

SQLiteTypeToGo is a convenience function that uses default type mapping (kept for backward compatibility where no custom types are needed)

Types

type Analyzer

type Analyzer struct {
	Catalog     *model.Catalog
	CustomTypes map[string]config.CustomTypeMapping
	// contains filtered or unexported fields
}

Analyzer validates queries against the schema catalog.

func New

func New(catalog *model.Catalog) *Analyzer

New creates a new Analyzer with the given catalog.

func NewWithCustomTypes

func NewWithCustomTypes(catalog *model.Catalog, customTypes map[string]config.CustomTypeMapping) *Analyzer

NewWithCustomTypes creates a new Analyzer with the given catalog and custom type mappings.

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(q parser.Query) Result

Analyze validates and resolves a parsed query.

func (*Analyzer) SQLiteTypeToGo

func (a *Analyzer) SQLiteTypeToGo(sqliteType string) string

SQLiteTypeToGo converts a SQLite type to a Go type. If a TypeResolver is set, it will be used for database-specific type mapping.

func (*Analyzer) SetTypeResolver

func (a *Analyzer) SetTypeResolver(resolver TypeResolver)

SetTypeResolver sets the type resolver for database-specific type mapping.

type Diagnostic

type Diagnostic struct {
	Path     string
	Line     int
	Column   int
	Message  string
	Severity Severity
}

Diagnostic represents an issue found during analysis.

type Result

type Result struct {
	Query       parser.Query
	Columns     []ResultColumn
	Params      []ResultParam
	Diagnostics []Diagnostic
}

Result contains the analysis result for a single query.

type ResultColumn

type ResultColumn struct {
	Name     string
	Table    string
	GoType   string
	Nullable bool
}

ResultColumn describes a single output column of a query.

type ResultParam

type ResultParam struct {
	Name          string
	Style         parser.ParamStyle
	GoType        string
	Nullable      bool
	IsVariadic    bool
	VariadicCount int
}

ResultParam describes a single input parameter of a query.

type Severity

type Severity int

Severity indicates the seriousness of a diagnostic.

const (
	// SeverityWarning indicates a potential issue that doesn't prevent code generation.
	SeverityWarning Severity = iota
	// SeverityError indicates a fatal issue that prevents code generation.
	SeverityError
)

type TypeInfo

type TypeInfo struct {
	GoType      string
	UsesSQLNull bool
	Import      string
	Package     string
}

TypeInfo describes a resolved Go type.

type TypeResolver

type TypeResolver interface {
	ResolveType(sqlType string, nullable bool) TypeInfo
}

TypeResolver interface for database-specific type mapping.

Jump to

Keyboard shortcuts

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