exec

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KindUndefined undefined kind
	KindUndefined = Kind(iota)
	//KindCreateTable create table
	KindCreateTable
	//KindDropTable drop table
	KindDropTable
)
View Source
const (
	//ParameterKindLiteral literal
	ParameterKindLiteral = ParameterKind(1)
	//ParameterKindPlaceholder placeholder
	ParameterKindPlaceholder = ParameterKind(2)
	//ParameterKindField field
	ParameterKindField = ParameterKind(3)
	//ParameterKindColumn column
	ParameterKindColumn = ParameterKind(4)
	//ParameterKindValue values
	ParameterKindValue = ParameterKind(5)
)
View Source
const (
	//StrategyPartiql defines execution strategy
	StrategyPartiql = Strategy("partiql")
)

Variables

This section is empty.

Functions

func Convert

func Convert(attributeType string) reflect.Type

Convert converts attribute to relect type

func Encode

func Encode(value interface{}) (types.AttributeValue, error)

Encode encodes value

func Register

func Register(name string, newFunc NewFunc)

Register register custom function

Types

type Column

type Column struct {
	Pos    int
	Name   string
	Fields []int
	Type   reflect.Type
	Func   Function
}

Column represents projection column

func (c *Column) Link(field *Field)

Link links field with column

type Execution

type Execution struct {
	Kind     Kind
	SQL      string
	Table    string
	HasTable bool

	Create *table.Create
	Drop   *table.Drop
	Type   *Type
	Parti  *PartiQL
	Limit  *int32
	// contains filtered or unexported fields
}

Execution represent execution

func NewCreateTable

func NewCreateTable(table string, stmt *table.Create, desc *types.TableDescription) (*Execution, error)

NewCreateTable returns create Table execution

func NewDelete

func NewDelete(table string, stmt *del.Statement, desc *types.TableDescription) (*Execution, error)

NewDelete creates an update execution

func NewDropTable

func NewDropTable(table string, stmt *table.Drop, desc *types.TableDescription) (*Execution, error)

NewDropTable returns drop Table execution

func NewInsert

func NewInsert(table string, stmt *insert.Statement, desc *types.TableDescription) (*Execution, error)

NewInsert creates an insert execution

func NewQuery

func NewQuery(table string, query *query.Select, desc *types.TableDescription) (*Execution, error)

NewQuery creates an query execution

func NewUpdate

func NewUpdate(table string, stmt *insert.Statement, desc *types.TableDescription) (*Execution, error)

NewUpdate creates an update execution

func (*Execution) CreateTableInput

func (e *Execution) CreateTableInput() (*dynamodb.CreateTableInput, error)

CreateTableInput returns create table input

func (*Execution) DeleteTableInput

func (e *Execution) DeleteTableInput() (*dynamodb.DeleteTableInput, error)

DeleteTableInput returns delete table input

func (*Execution) NewState

func (e *Execution) NewState(args []driver.NamedValue) *State

NewState ctates a state

func (*Execution) ReleaseState

func (e *Execution) ReleaseState(state *State)

ReleaseState releases state

type Field

type Field struct {
	Pos  int
	Name string

	Type reflect.Type

	Required bool
	Decoder  func(dec *gojay.Decoder) (interface{}, error)
	// contains filtered or unexported fields
}

Field represents underlying storage field

func (*Field) IsSlice

func (f *Field) IsSlice() bool

IsSlice returns true if a filed is slice

type Function

type Function interface {
	//Exec runs function logic
	Exec(value interface{}, state *State) (interface{}, error)
}

Function user defined function interface

type Kind

type Kind int

Kind represents execution king

type NewFunc

type NewFunc func(call *expr.Call, rowType *Type) (Function, reflect.Type, error)

NewFunc function provider

func Lookup

func Lookup(name string) NewFunc

Lookup returns custom function

type Parameter

type Parameter struct {
	Name  string
	Type  reflect.Type
	Kind  ParameterKind
	Pos   int
	Value interface{} //for constants
}

Parameter represents query parameters

func NewColumn

func NewColumn(name string, pos int) *Parameter

NewColumn returns a column param

func NewField

func NewField(name string) *Parameter

NewField returns a field param

func NewLiteral

func NewLiteral(text string, kind string) *Parameter

NewLiteral returns a literal param

func NewPlaceholder

func NewPlaceholder(name string) *Parameter

NewPlaceholder returns a placeholder param

func NewValue

func NewValue() *Parameter

NewValue returns a value param

type ParameterKind

type ParameterKind string

ParameterKind defines parameter king

type Parameters

type Parameters struct {
	BindingLen int
	List       []*Parameter
	Criteria   []*Parameter
	// contains filtered or unexported fields
}

Parameters parameter collections

func (*Parameters) AddCriteria

func (p *Parameters) AddCriteria(param *Parameter)

AddCriteria add criteria paramaeter

func (*Parameters) AddItem

func (p *Parameters) AddItem(param *Parameter)

AddItem add param

func (*Parameters) NumInput

func (p *Parameters) NumInput() int

NumInput returns num inputs

type PartiQL

type PartiQL struct {
	Query string
}

PartiQL represent PrtiQA

type State

type State struct {
	Type    *Type
	Fields  []driver.Value
	Columns []driver.Value
	Reset   []driver.Value
	Args    []driver.NamedValue
	// contains filtered or unexported fields
}

State represent an execution state

func NewState added in v0.1.2

func NewState(sType *Type, args []driver.NamedValue) *State

func (*State) Init

func (s *State) Init() error

Init initialise state

func (*State) NKeys

func (s *State) NKeys() int

NKeys returns keys

func (*State) ProjectionListParameters

func (s *State) ProjectionListParameters() ([]types.AttributeValue, error)

ProjectionListParameters returns list attributes

func (*State) QueryParameters

func (s *State) QueryParameters() ([]types.AttributeValue, error)

QueryParameters returns query params

func (*State) Reconcile

func (s *State) Reconcile() error

Reconcile reconcile state

func (*State) SetDest

func (s *State) SetDest(dest []driver.Value)

SetDest set destination values

func (*State) UnmarshalJSONObject

func (s *State) UnmarshalJSONObject(dec *gojay.Decoder, k string) (err error)

UnmarshalJSONObject implements gojay's UnmarshalerJSONObject

func (*State) Values

func (s *State) Values(value interface{}, parameters []*Parameter) ([]interface{}, error)

Values returns values

type Strategy

type Strategy string

Strategy represents a strategy

type Type

type Type struct {
	Parameters
	Wildcard bool
	Fields   []Field

	Columns []Column
	Keys    map[string]types.KeyType
	// contains filtered or unexported fields
}

Type represent execution tpye

func NewType

func NewType(wildcard bool) *Type

NewType creates a new type

func (*Type) Add

func (t *Type) Add(fName, cName, attrType string, isRequired bool) *Field

Add adds field and column and link

func (*Type) AddCriteria

func (t *Type) AddCriteria(param *Parameter)

AddCriteria adds criteria

func (*Type) AddItem

func (t *Type) AddItem(param *Parameter)

AddItem add param

func (*Type) Column

func (t *Type) Column(name string) *Column

Column returns a column

func (*Type) Field

func (t *Type) Field(name string) *Field

Field returns a filed

func (*Type) Init

func (t *Type) Init() error

Init initialise type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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