parser

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ParenthesesBlockToken int

	IfBlockToken

	ComponentKeyword
)
View Source
const (
	InKeyword  = "in"
	OrKeyword  = "or"
	AndKeyword = "and"
)

Variables

View Source
var ComponentKeywordMatcher = parsly.NewToken(ComponentKeyword, "@component", matcher.NewFragment("@component"))
View Source
var IfBlockMatcher = parsly.NewToken(IfBlockToken, "if block", imatchers.NewIfBlock())
View Source
var ParenthesesBlockMatcher = parsly.NewToken(ParenthesesBlockToken, "Parentheses", matcher.NewBlock('(', ')', '\\'))

Functions

func CanBeParam

func CanBeParam(name string) bool

func DefaultOAuthParameter

func DefaultOAuthParameter(name string) *inference.Parameter

DefaultOAuthParameter creates a default oauht parameter

func ExtractParameterHints

func ExtractParameterHints(text string, state *inference.State) error

func GetHolderName

func GetHolderName(identifier string) (string, string)

func GetHolderNameFromSelector

func GetHolderNameFromSelector(selector *expr.Select) (string, string)

func IsStructQL

func IsStructQL(SQL string) bool

IsStructQL returns true if struct QL

func MergeStructs

func MergeStructs(args ...interface{}) ([]byte, error)

func OnVeltyExpression

func OnVeltyExpression() sqlparser.Option

func ParseImports

func ParseImports(ctx context.Context, expr *string, handler func(ctx context.Context, spec *TypeImport) error) error

ParseImports parse go types import statement

func RemoveParameterHints

func RemoveParameterHints(text string, state inference.State) string

func SplitByWhitespace

func SplitByWhitespace(fragment string) []string

func SplitHint

func SplitHint(hint string) (marshal string, SQL string)

SplitHint split hint into json and optionally SQL

Types

type Context

type Context int
const (
	UnspecifiedContext Context = iota
	SetContext
	IfContext
	ForEachContext
	AppendContext
	FuncContext
)

type Declaration

type Declaration struct {
	inference.Parameter
	//ParametersState shorthands
	Auth          string            `json:",omitempty" yaml:",omitempty"`
	Kind          string            `json:",omitempty" yaml:",omitempty"`
	Location      *string           `json:",omitempty" yaml:",omitempty"`
	OutputType    string            `json:",omitempty" yaml:",omitempty"`
	Cardinality   state.Cardinality `json:",omitempty" yaml:",omitempty"`
	StatusCode    *int              `json:",omitempty" yaml:",omitempty"`
	ErrorMessage  *string           `json:",omitempty" yaml:",omitempty"`
	TransformKind string            `json:",omitempty" yaml:",omitempty"`
	Transformer   string            `json:",omitempty" yaml:",omitempty"`
	Codec         string            `json:",omitempty" yaml:",omitempty"`
	CodecArgs     []string          `json:",omitempty" yaml:",omitempty"`
	QuerySelector string            `json:",omitempty" yaml:",omitempty"`
	Raw           string
}

func (*Declaration) AuthParameter

func (d *Declaration) AuthParameter() *inference.Parameter

func (*Declaration) ExpandShorthands

func (d *Declaration) ExpandShorthands()

func (*Declaration) Merge

func (d *Declaration) Merge(from *Declaration) (*Declaration, error)

func (*Declaration) PathWithName

func (d *Declaration) PathWithName() (string, string)

func (*Declaration) Transform

func (d *Declaration) Transform() *marshal.Transform

type Declarations

type Declarations struct {
	SQL            string
	State          inference.State
	OutputState    inference.State
	AsyncState     inference.State
	QuerySelectors map[string]inference.State
	Transforms     []*marshal.Transform

	Items []*Declaration
	// contains filtered or unexported fields
}

Declarations defines state (parameters) declaration

func NewDeclarations

func NewDeclarations(SQL string, lookup func(dataType string, opts ...xreflect.Option) (*state.Schema, error)) (*Declarations, error)

func (*Declarations) Init

func (d *Declarations) Init() error

type Expression

type Expression struct {
	Start           int
	End             int
	FullName        string
	Prefix          string
	Holder          string
	Context         Context
	FnName          string
	IsVariable      bool
	OccurrenceIndex int
	SQLKeyword      string
	Entry           *functions.Entry
}

type ExpressionContext

type ExpressionContext struct {
	Name      string
	Context   Context
	Function  string
	Fragments []string
	Column    string
	Type      reflect.Type
}

func NewParamContext

func NewParamContext(name string, fnName string, context Context) *ExpressionContext

func (*ExpressionContext) BeforeElements

func (c *ExpressionContext) BeforeElements() []string

func (*ExpressionContext) IsJSONCodec

func (c *ExpressionContext) IsJSONCodec() bool

type Expressions

type Expressions []*Expression

type Statement

type Statement struct {
	Start          int
	End            int
	Kind           string
	IsExec         bool
	Selector       *expr.Select
	SelectorMethod string
	Table          string
}

type Statements

type Statements []*Statement

func NewStatements

func NewStatements(SQL string) Statements

func (Statements) DMLTables

func (s Statements) DMLTables(rawSQL string) []string

func (Statements) IsExec

func (s Statements) IsExec() bool

type Template

type Template struct {
	SQL      string
	Declared map[string]bool
	State    *inference.State
	Context  []*ExpressionContext
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(SQL string, state *inference.State) (*Template, error)

func (*Template) DetectTypes

func (t *Template) DetectTypes(handler func(state *inference.State, parameter string, expression *ExpressionContext))

func (*Template) Sanitize

func (t *Template) Sanitize() string

type TypeImport

type TypeImport struct {
	URL            string
	Types          []string
	Alias          string
	Methods        []reflect.Method
	ForceGoTypeUse bool
}

func (*TypeImport) EnsureLocation

func (t *TypeImport) EnsureLocation(ctx context.Context, fs afs.Service, rootPath, goModuleLocation string)

type TypeImports

type TypeImports []*TypeImport

func (*TypeImports) Append

func (t *TypeImports) Append(spec *TypeImport)

func (TypeImports) Lookup

func (t TypeImports) Lookup(typeName string) *TypeImport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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