expand

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: Apache-2.0 Imports: 41 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

This section is empty.

Variables

View Source
var PredicateCtx predicateCtx = "ctx"
View Source
var PredicateState predicateState = "state"

Functions

func AsBindings

func AsBindings(key string, values []interface{}) (column string, bindings string)

func NotZeroOf

func NotZeroOf(values ...int) int

func SetPanicOnError

func SetPanicOnError(value bool)

Types

type BindingsCache

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

func (*BindingsCache) Lookup

func (b *BindingsCache) Lookup(value interface{}) (BindingsExpander, error)

type BindingsExpander

type BindingsExpander interface {
	HasAny(value interface{}) bool
	Expand(source string, value interface{}) ([]*Expression, error)
	ColumnExpression(source string) string
}

type Callback

type Callback func(object interface{}, err error) error

type ConstUpdater

type ConstUpdater interface {
	UpdateValue(params interface{}, presenceMap interface{}) error
}

type Context

type Context struct {
	Printer           *Printer           `velty:"names=logger|fmt"`
	DataUnit          *DataUnit          `velty:"names=sql|sqlx|sequencer|criteria"`
	Http              *Http              `velty:"names=http"`
	ResponseBuilder   *ResponseBuilder   `velty:"names=response"`
	ViewContext       *ViewContext       `velty:"names=View"`
	ParentViewContext *ViewContext       `velty:"names=ParentView"`
	Session           *extension.Session `velty:"names=session"`
	Validator         *validator.Service `velty:"names=validator"`
	MessageBus        *mbus.Service      `velty:"names=messageBus"`
	Predicate         *Predicate         `velty:"names=predicate"`
	Filters           predicate.Filters  `velty:"names=filters"`
}

type CriteriaColumn

type CriteriaColumn struct {
	Name  string
	Alias string
	Field *xunsafe.Field
}

func ParseDatlyTag

func ParseDatlyTag(field reflect.StructField) (*CriteriaColumn, error)

type CriteriaExpander

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

func (*CriteriaExpander) ColumnExpression

func (c *CriteriaExpander) ColumnExpression(source string) string

func (*CriteriaExpander) Expand

func (c *CriteriaExpander) Expand(source string, value interface{}) ([]*Expression, error)

func (*CriteriaExpander) HasAny

func (c *CriteriaExpander) HasAny(value interface{}) bool

type DataUnit

type DataUnit struct {
	Columns     codec.ColumnsSource
	ParamsGroup []interface{}
	Mock        bool
	TemplateSQL string
	MetaSource  Dber        `velty:"-"`
	Statements  *Statements `velty:"-"`
	// contains filtered or unexported fields
}

func NewDataUnit

func NewDataUnit(metaSource Dber) *DataUnit

func (*DataUnit) Add

func (c *DataUnit) Add(_ int, value interface{}) (string, error)

func (*DataUnit) Allocate

func (c *DataUnit) Allocate(tableName string, dest interface{}, selector string) (string, error)

func (*DataUnit) AppendBinding

func (c *DataUnit) AppendBinding(value interface{}) (string, error)

func (*DataUnit) AsBinding

func (c *DataUnit) AsBinding(value interface{}) (string, error)

func (*DataUnit) AsColumn

func (c *DataUnit) AsColumn(columnName string) (string, error)

func (*DataUnit) At

func (c *DataUnit) At(_ int) []interface{}

func (*DataUnit) Contains

func (c *DataUnit) Contains(columnName string, args interface{}) (string, error)

func (*DataUnit) Delete

func (c *DataUnit) Delete(data interface{}, name string) (string, error)

func (*DataUnit) FilterExecutables

func (c *DataUnit) FilterExecutables(statements []string, stopOnNonExec bool) []*Executable

func (*DataUnit) In

func (c *DataUnit) In(columnName string, args interface{}) (string, error)

func (*DataUnit) Insert

func (c *DataUnit) Insert(data interface{}, tableName string) (string, error)

func (*DataUnit) IsServiceExec

func (c *DataUnit) IsServiceExec(SQL string) (*Executable, bool)

func (*DataUnit) Like

func (c *DataUnit) Like(columnName string, args interface{}) (string, error)

func (*DataUnit) Next

func (c *DataUnit) Next() (interface{}, error)

func (*DataUnit) NotContains

func (c *DataUnit) NotContains(columnName string, args interface{}) (string, error)

func (*DataUnit) NotIn

func (c *DataUnit) NotIn(columnName string, args interface{}) (string, error)

func (*DataUnit) NotLike

func (c *DataUnit) NotLike(columnName string, args interface{}) (string, error)

func (*DataUnit) UUID

func (c *DataUnit) UUID() string

func (*DataUnit) Update

func (c *DataUnit) Update(data interface{}, tableName string) (string, error)

func (*DataUnit) Validate

func (c *DataUnit) Validate(dest interface{}, opts ...interface{}) (*validator.Validation, error)

func (*DataUnit) WithLocation

func (c *DataUnit) WithLocation(loc string) interface{}

func (*DataUnit) WithPresence

func (c *DataUnit) WithPresence() interface{}

type Dber

type Dber interface {
	Db() (*sql.DB, error)
}

type Dereferencer

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

func (*Dereferencer) Fields

func (f *Dereferencer) Fields(rType reflect.Type) []*xunsafe.Field

type Differ

type Differ struct{}

func (Differ) Diff

func (d Differ) Diff(from interface{}, fo interface{}) *godiff.ChangeLog

type EmbeddableMap

type EmbeddableMap map[string]interface{}

type ErrorHandler

type ErrorHandler func(err error) error

type ErrorResponse

type ErrorResponse struct {
	Content    EmbeddableMap
	Message    string
	StatusCode int
}

func (*ErrorResponse) Error

func (h *ErrorResponse) Error() string

func (*ErrorResponse) ErrorMessage

func (h *ErrorResponse) ErrorMessage() string

func (*ErrorResponse) ErrorStatusCode

func (h *ErrorResponse) ErrorStatusCode() int

type Evaluator

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

func NewEvaluator

func NewEvaluator(template string, options ...EvaluatorOption) (*Evaluator, error)

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(ctx *Context, options ...StateOption) (*State, error)

func (*Evaluator) Type

func (e *Evaluator) Type() reflect.Type

type EvaluatorOption

type EvaluatorOption func(c *config)

func WithCustomContexts

func WithCustomContexts(ctx ...*Variable) EvaluatorOption

func WithPanicOnError

func WithPanicOnError(b bool) EvaluatorOption

func WithPredicates

func WithPredicates(configs []*PredicateConfig) EvaluatorOption

func WithSetLiteral

func WithSetLiteral(setLiterals func(state *structology.State) error) EvaluatorOption

func WithStateName

func WithStateName(name string) EvaluatorOption

func WithStateType

func WithStateType(stateType *structology.StateType) EvaluatorOption

func WithTypeLookup

func WithTypeLookup(lookup xreflect.LookupType) EvaluatorOption

func WithVariable

func WithVariable(namedVariable ...*NamedVariable) EvaluatorOption

type ExecType

type ExecType int
const (
	ExecTypeInsert ExecType = iota
	ExecTypeUpdate
	ExecTypeDelete
)

type Executable

type Executable struct {
	Table    string
	ExecType ExecType
	Data     interface{}
	IsLast   bool
	// contains filtered or unexported fields
}

func (*Executable) Executed

func (e *Executable) Executed() bool

func (*Executable) MarkAsExecuted

func (e *Executable) MarkAsExecuted()

type ExecutablesIndex

type ExecutablesIndex map[string]*Executable

func (ExecutablesIndex) UpdateLastExecutable

func (i ExecutablesIndex) UpdateLastExecutable(execType ExecType, tableName string, newExecutable *Executable)

type Expander

type Expander interface {
	ColIn(prefix, column string) (string, error)
	In(prefix string) (string, error)
	ParentJoinOn(column string, prepend ...string) (string, error)
	AndParentJoinOn(column string) (string, error)
}

type Expression

type Expression struct {
	ColumnExpression string
	SQLFragment      *strings.Builder
	Args             []interface{}
}

func NewSingleExpression

func NewSingleExpression(expression string, fragment string, args []interface{}) []*Expression

type Flushable

type Flushable struct {
	Handler  func() error
	OnStatus HTTPStatus
}

type HTTPStatus

type HTTPStatus int
const (
	StatusUnspecified HTTPStatus = iota
	StatusDefault
	StatusFailure
	StatusSuccess
)

type Http

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

func (*Http) Defer

func (h *Http) Defer() HTTPStatus

func (*Http) DeferOnFailure

func (h *Http) DeferOnFailure() HTTPStatus

func (*Http) DeferOnSuccess

func (h *Http) DeferOnSuccess() HTTPStatus

func (*Http) Do

func (h *Http) Do(method string, URL string, input interface{}, args ...interface{}) (HttpResponse, error)

func (*Http) Flush

func (h *Http) Flush(status HTTPStatus) error

func (*Http) Get

func (h *Http) Get(url string) (HttpResponse, error)

func (*Http) OnError

func (h *Http) OnError(callback Callback) ErrorHandler

func (*Http) OnSuccess

func (h *Http) OnSuccess(callback Callback) ErrorHandler

func (*Http) Post

func (h *Http) Post(url string, body interface{}) (HttpResponse, error)

func (*Http) StatusCode

func (h *Http) StatusCode(code int) StatusCode

type HttpResponse

type HttpResponse struct {
	HttpValidation
	IsPostponed bool
	StatusCode  int
	Body        string
}

type HttpValidation

type HttpValidation struct {
	Invalid bool
	Message string
}

type MockExpander

type MockExpander struct{}

func (*MockExpander) AndParentJoinOn

func (e *MockExpander) AndParentJoinOn(column string) (string, error)

func (*MockExpander) ColIn

func (e *MockExpander) ColIn(prefix, column string) (string, error)

func (*MockExpander) In

func (e *MockExpander) In(prefix string) (string, error)

func (*MockExpander) ParentJoinOn

func (e *MockExpander) ParentJoinOn(column string, prepend ...string) (string, error)

type NamedVariable

type NamedVariable struct {
	Variable
	Name string
}

func (*NamedVariable) New

func (v *NamedVariable) New(value interface{}) *NamedVariable

type ParentBatch

type ParentBatch interface {
	ColIn() []interface{}
	ColInBatch() []interface{}
}

type ParentExtras

type ParentExtras interface {
	CurrentLimit() int
	CurrentOffset() int
	CurrentPage() int
}

type ParentSource

type ParentSource interface {
	Dber
	ViewName() string
	TableAlias() string
	TableName() string
	ResultLimit() int
}

type Predicate

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

func NewPredicate

func NewPredicate(ctx *Context, state *structology.State, config []*PredicateConfig) *Predicate

func (*Predicate) Builder

func (p *Predicate) Builder() *PredicateBuilder

func (*Predicate) Expand

func (p *Predicate) Expand(ctx int) (string, error)

func (*Predicate) ExpandWith

func (p *Predicate) ExpandWith(ctx int, operator string) (string, error)

func (*Predicate) FilterGroup

func (p *Predicate) FilterGroup(group int, keyword string) (string, error)

type PredicateBuilder

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

func (*PredicateBuilder) And

func (*PredicateBuilder) Build

func (b *PredicateBuilder) Build(keyword string) string

func (*PredicateBuilder) Combine

func (b *PredicateBuilder) Combine(fragments ...string) *PredicateBuilder

func (*PredicateBuilder) CombineAnd

func (b *PredicateBuilder) CombineAnd(fragments ...string) *PredicateBuilder

func (*PredicateBuilder) CombineOr

func (b *PredicateBuilder) CombineOr(fragments ...string) *PredicateBuilder

func (*PredicateBuilder) Or

type PredicateConfig

type PredicateConfig struct {
	Group    int
	Selector *structology.Selector `velty:"-"`
	Expander codec.PredicateHandler
	Ensure   bool
}

type PrimitiveExpander

type PrimitiveExpander struct {
}

func (*PrimitiveExpander) ColumnExpression

func (p *PrimitiveExpander) ColumnExpression(source string) string

func (*PrimitiveExpander) Expand

func (p *PrimitiveExpander) Expand(source string, value interface{}) ([]*Expression, error)

func (*PrimitiveExpander) HasAny

func (p *PrimitiveExpander) HasAny(value interface{}) bool

type Printer

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

func (*Printer) Debugf

func (p *Printer) Debugf(format string, params ...interface{}) string

func (*Printer) Discover

func (p *Printer) Discover(aFunc interface{}) (func(operands []*op.Operand, state *est.State) (interface{}, error), reflect.Type, bool)

func (*Printer) Fatal

func (p *Printer) Fatal(any interface{}, args ...interface{}) (string, error)

func (*Printer) Fatalf

func (p *Printer) Fatalf(any interface{}, args ...interface{}) (string, error)

Fatalf fatal with formatting

func (*Printer) FatalfWithCode

func (p *Printer) FatalfWithCode(code int, any interface{}, args ...interface{}) (string, error)

FatalfWithCode logs and terminate with status code

func (*Printer) Flush

func (p *Printer) Flush()

func (*Printer) Log

func (p *Printer) Log(format string, args ...interface{}) string

func (*Printer) Logf

func (p *Printer) Logf(format string, args ...interface{}) string

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...interface{}) string

func (*Printer) Println

func (p *Printer) Println(args ...interface{}) string

func (*Printer) Sprintf

func (p *Printer) Sprintf(format string, args ...interface{}) string

type ResponseBuilder

type ResponseBuilder struct {
	Content      map[string]interface{} `velty:"-"`
	ResponseCode int                    `velty:"-"`
}

func (*ResponseBuilder) Add

func (b *ResponseBuilder) Add(key string, value interface{}) string

func (*ResponseBuilder) CallbackAdd

func (b *ResponseBuilder) CallbackAdd(key string, value interface{}) Callback

func (*ResponseBuilder) CallbackFailf

func (b *ResponseBuilder) CallbackFailf(format string, args ...interface{}) Callback

func (*ResponseBuilder) CallbackFailfWithStatusCode

func (b *ResponseBuilder) CallbackFailfWithStatusCode(statusCode int, format string, args ...interface{}) Callback

func (*ResponseBuilder) CallbackPut

func (b *ResponseBuilder) CallbackPut(key string, value interface{}) Callback

func (*ResponseBuilder) CallbackStatusCode

func (b *ResponseBuilder) CallbackStatusCode(statusCode int) Callback

func (*ResponseBuilder) Failf

func (b *ResponseBuilder) Failf(format string, args ...interface{}) (string, error)

func (*ResponseBuilder) FailfWithStatusCode

func (b *ResponseBuilder) FailfWithStatusCode(statusCode int, format string, args ...interface{}) (string, error)

func (*ResponseBuilder) Put

func (b *ResponseBuilder) Put(key string, value interface{}) string

func (*ResponseBuilder) StatusCode

func (b *ResponseBuilder) StatusCode(statusCode int) string

type SQLStatment

type SQLStatment struct {
	SQL  string
	Args []interface{}
}

type SliceExpander

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

func (*SliceExpander) ColumnExpression

func (s *SliceExpander) ColumnExpression(source string) string

func (*SliceExpander) Expand

func (s *SliceExpander) Expand(source string, value interface{}) ([]*Expression, error)

func (*SliceExpander) HasAny

func (s *SliceExpander) HasAny(value interface{}) bool

type State

type State struct {
	*est.State
	*Context
	ParametersState  *structology.State
	EmbededVariables []*Variable
	NamedVariables   []*NamedVariable

	Expanded string
	// contains filtered or unexported fields
}

func StateWithSQL

func StateWithSQL(SQL string) *State

func (*State) Flush

func (s *State) Flush(status HTTPStatus) error

func (*State) Init

func (s *State) Init(templateState *est.State, predicates []*PredicateConfig, options ...StateOption)

type StateOption

type StateOption func(state *State)

func WithCustomContext

func WithCustomContext(customContext *Variable) StateOption

func WithDataUnit

func WithDataUnit(dataUnit *DataUnit) StateOption

func WithNamedVariables

func WithNamedVariables(variables ...*NamedVariable) StateOption

func WithParameterState

func WithParameterState(parametersState *structology.State) StateOption

func WithParentViewParam

func WithParentViewParam(viewParam *ViewContext) StateOption

func WithSession

func WithSession(session *extension.Session) StateOption

func WithViewParam

func WithViewParam(viewParam *ViewContext) StateOption

type Statements

type Statements struct {
	Executable []interface{}
	Index      ExecutablesIndex
	Markers    map[string]int
	// contains filtered or unexported fields
}

func NewStmtHolder

func NewStmtHolder() *Statements

func (*Statements) Delete

func (s *Statements) Delete(name string, data interface{})

func (*Statements) DeleteWithMarker

func (s *Statements) DeleteWithMarker(tableName string, data interface{}) string

func (*Statements) Execute

func (s *Statements) Execute(SQLStmt *SQLStatment)

func (*Statements) FilterByTableName

func (s *Statements) FilterByTableName(name string) []interface{}

func (*Statements) Insert

func (s *Statements) Insert(tableName string, data interface{})

func (*Statements) InsertWithMarker

func (s *Statements) InsertWithMarker(tableName string, data interface{}) string

func (*Statements) LookupExecutable

func (s *Statements) LookupExecutable(sql string) (*Executable, bool)

func (*Statements) NextNonExecuted

func (s *Statements) NextNonExecuted() (*Executable, bool)

func (*Statements) Update

func (s *Statements) Update(tableName string, data interface{})

func (*Statements) UpdateWithMarker

func (s *Statements) UpdateWithMarker(tableName string, data interface{}) string

type StatusCode

type StatusCode int

type Validator

type Validator struct {
	Service *govalidator.Service
}

func CommonValidator

func CommonValidator() *Validator

func NewValidator

func NewValidator() *Validator

NewValidator creates a validator

func (*Validator) Validate

func (c *Validator) Validate(dest interface{}, opts ...interface{}) (*govalidator.Validation, error)

Validate validates destination

func (*Validator) WithLocation

func (c *Validator) WithLocation(loc string) govalidator.Option

func (*Validator) WithPresence

func (c *Validator) WithPresence() govalidator.Option

type Variable

type Variable struct {
	Type  reflect.Type
	Value interface{}
}

func (*Variable) Validate

func (v *Variable) Validate() error

type ViewContext

type ViewContext struct {
	Name         string
	Alias        string
	Table        string
	Limit        int
	Offset       int
	Page         int
	Args         []interface{}
	NonWindowSQL string
	ParentValues []interface{}

	DataUnit *DataUnit `velty:"-"`
	// contains filtered or unexported fields
}

func NewViewContext

func NewViewContext(metaSource ParentSource, aSelector ParentExtras, batchData ParentBatch, options ...interface{}) *ViewContext

func (*ViewContext) AndParentJoinOn

func (m *ViewContext) AndParentJoinOn(column string) (string, error)

func (*ViewContext) ColIn

func (m *ViewContext) ColIn(prefix, column string) (string, error)

func (*ViewContext) Expand

func (m *ViewContext) Expand(_ *DataUnit) string

AddRelation appends SQL and adds binding arguments Deprecated: For the backward compatibility

func (*ViewContext) In

func (m *ViewContext) In(prefix string) (string, error)

func (*ViewContext) ParentJoinOn

func (m *ViewContext) ParentJoinOn(column string, prepend ...string) (string, error)

Jump to

Keyboard shortcuts

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