sql_adaptor

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldParseValidatorFromStruct

func FieldParseValidatorFromStruct(gorm reflect.Value) map[string]ParseValidateFunc

FieldParseValidatorFromStruct TODO: gorm.model gets included as a valid field which we probably don't want. Don't panic - reflection is only used once on initialisation.

func IntegerValidator

func IntegerValidator(s string) error

func NullValidator

func NullValidator(_ string) error

func NumericValidator

func NumericValidator(s string) error

Types

type ParseValidateFunc

type ParseValidateFunc = func(ex *parser.Expression) (*SqlResponse, error)

ParseValidateFunc takes an Expression from the AST and returns a templated SQL query.

func DefaultMatcherWithValidator

func DefaultMatcherWithValidator(validate ValidatorFunc) ParseValidateFunc

DefaultMatcherWithValidator wraps the default matcher with validation on the value.

type SqlAdaptor

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

func NewDefaultAdaptorFromStruct

func NewDefaultAdaptorFromStruct(gorm reflect.Value) (*SqlAdaptor, error)

func NewSqlAdaptor

func NewSqlAdaptor(fieldMappings map[string]string, defaultFields map[string]ParseValidateFunc, matchers map[*regexp.Regexp]ParseValidateFunc) *SqlAdaptor

func (*SqlAdaptor) Parse

func (s *SqlAdaptor) Parse(str string) (*SqlResponse, error)

type SqlResponse

type SqlResponse struct {
	Raw    string
	Values []string
}

func DefaultMatcher

func DefaultMatcher(ex *parser.Expression) *SqlResponse

DefaultMatcher takes an expression and spits out the default SqlResponse.

type ValidatorFunc

type ValidatorFunc = func(s string) error

ValidatorFunc takes a field name and validates that it is a legal/correct format.

Jump to

Keyboard shortcuts

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