vet

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQueryArgUnsupportedType = errors.New("unexpected query arg type")
	ErrQueryArgUnsafe          = errors.New("potentially unsafe query string")
	ErrQueryArgTODO            = errors.New("TODO: support this type")
)

Functions

func AddQueryParam added in v1.0.3

func AddQueryParam(target *[]QueryParam, param QueryParam)

insert query param based on parameter number and avoid deduplications

func AddQueryParams added in v1.0.3

func AddQueryParams(target *[]QueryParam, params []QueryParam)

func DebugQuery

func DebugQuery(q string)

Types

type ColumnUsed

type ColumnUsed struct {
	Column   string
	Table    string
	Location int32
}

type MatchedSqlFunc

type MatchedSqlFunc struct {
	SSA         *ssa.Function
	QueryArgPos int
}

type ParseResult added in v1.0.3

type ParseResult struct {
	Columns []ColumnUsed
	Tables  []TableUsed
	Params  []QueryParam

	PostponedNodes *PostponedNodes
}

type PostponedNodes added in v1.1.7

type PostponedNodes struct {
	RangeSubselectNodes []*pg_query.RangeSubselect
}

func (*PostponedNodes) Append added in v1.1.7

func (p *PostponedNodes) Append(other *PostponedNodes)

func (*PostponedNodes) Parse added in v1.1.7

func (p *PostponedNodes) Parse(ctx VetContext, parseRe *ParseResult) (err error)

type QueryParam added in v1.0.3

type QueryParam struct {
	Number int32
}

func ValidateSqlQuery

func ValidateSqlQuery(ctx VetContext, queryStr string) ([]QueryParam, error)

type QuerySite

type QuerySite struct {
	Called            string
	Position          token.Position
	Query             string
	ParameterArgCount int
	Err               error
}

func CheckDir

func CheckDir(ctx VetContext, dir, buildFlags string, extraMatchers []SqlFuncMatcher) ([]*QuerySite, error)

type Schema added in v1.1.7

type Schema struct {
	Tables map[string]schema.Table
}

type SqlFuncMatchRule

type SqlFuncMatchRule struct {
	FuncName string `toml:"func_name"`
	// zero indexed
	QueryArgPos  int    `toml:"query_arg_pos"`
	QueryArgName string `toml:"query_arg_name"`
}

type SqlFuncMatcher

type SqlFuncMatcher struct {
	PkgPath string             `toml:"pkg_path"`
	Rules   []SqlFuncMatchRule `toml:"rules"`
	// contains filtered or unexported fields
}

func (*SqlFuncMatcher) IterPackageExportedFuncs

func (s *SqlFuncMatcher) IterPackageExportedFuncs(cb func(*types.Func))

func (*SqlFuncMatcher) MatchSqlFuncs

func (s *SqlFuncMatcher) MatchSqlFuncs(prog *ssa.Program) []MatchedSqlFunc

func (*SqlFuncMatcher) PackageImported

func (s *SqlFuncMatcher) PackageImported() bool

func (*SqlFuncMatcher) SetGoPackage

func (s *SqlFuncMatcher) SetGoPackage(p *packages.Package)

type SqlVetAnnotation

type SqlVetAnnotation struct {
	Ignore bool
}

func ParseComment

func ParseComment(comment string) (SqlVetAnnotation, error)

type TableUsed

type TableUsed struct {
	Name  string
	Alias string
}

type VetContext

type VetContext struct {
	Schema      Schema
	InnerSchema Schema
	UsedTables  []TableUsed
}

func NewContext added in v1.1.7

func NewContext(tables map[string]schema.Table) VetContext

Jump to

Keyboard shortcuts

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