vet

package
v0.0.0-...-cf2ca47 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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

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

insert query param based on parameter number and avoid deduplications

func AddQueryParams

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

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

	PostponedNodes *PostponedNodes
}

type PostponedNodes

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

func (*PostponedNodes) Append

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

func (*PostponedNodes) Parse

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

type QueryParam

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

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

type Sql0Annotation

type Sql0Annotation struct {
	Ignore bool
}

func ParseComment

func ParseComment(comment string) (Sql0Annotation, error)

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 TableUsed

type TableUsed struct {
	Name  string
	Alias string
}

type VetContext

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

func NewContext

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