qcode

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeStr parserType
	NodeInt
	NodeFloat
	NodeBool
	NodeObj
	NodeList
	NodeVar
)

Variables

This section is empty.

Functions

func AddFilter

func AddFilter(sel *Select, fil *Exp)

func FreeExp

func FreeExp(ex *Exp)

func FreeNode

func FreeNode(n *Node, loc int)

Types

type Action

type Action int

type AggregrateOp

type AggregrateOp int
const (
	AgCount AggregrateOp = iota + 1
	AgSum
	AgAvg
	AgMax
	AgMin
)

type Arg

type Arg struct {
	Name string
	Val  *Node
}

type Column

type Column struct {
	Table     string
	Name      string
	FieldName string
}

type Compiler

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

func NewCompiler

func NewCompiler(c Config) (*Compiler, error)

func (*Compiler) AddFilters

func (com *Compiler) AddFilters(qc *QCode, sel *Select, role string)

func (*Compiler) AddRole

func (com *Compiler) AddRole(role, table string, trc TRConfig) error

func (*Compiler) Compile

func (com *Compiler) Compile(query []byte, role string) (*QCode, error)

type Config

type Config struct {
	DefaultBlock bool
	Blocklist    []string
}

type DeleteConfig

type DeleteConfig struct {
	Filters []string
	Columns []string
	Block   bool
}

type Exp

type Exp struct {
	Op         ExpOp
	Col        string
	NestedCols []string
	Type       ValType
	Table      string
	Val        string
	ListType   ValType
	ListVal    []string
	Children   []*Exp
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter() *Exp

func (*Exp) Reset

func (ex *Exp) Reset()

type ExpOp

type ExpOp int
const (
	OpNop ExpOp = iota
	OpAnd
	OpOr
	OpNot
	OpEquals
	OpNotEquals
	OpGreaterOrEquals
	OpLesserOrEquals
	OpGreaterThan
	OpLesserThan
	OpIn
	OpNotIn
	OpLike
	OpNotLike
	OpILike
	OpNotILike
	OpSimilar
	OpNotSimilar
	OpContains
	OpContainedIn
	OpHasKey
	OpHasKeyAny
	OpHasKeyAll
	OpIsNull
	OpEqID
	OpTsQuery
	OpFalse
	OpNotDistinct
	OpDistinct
)

func (ExpOp) String

func (t ExpOp) String() string

type Field

type Field struct {
	ID       int32
	ParentID int32
	Name     string
	Alias    string
	Args     []Arg

	Children []int32
	// contains filtered or unexported fields
}

type InsertConfig

type InsertConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type Node

type Node struct {
	Type     parserType
	Name     string
	Val      string
	Parent   *Node
	Children []*Node
	// contains filtered or unexported fields
}

func ParseArgValue

func ParseArgValue(argVal string) (*Node, error)

func (*Node) Reset

func (n *Node) Reset()

type Operation

type Operation struct {
	Type parserType
	Name string
	Args []Arg

	Fields []Field
	// contains filtered or unexported fields
}

func Parse

func Parse(gql []byte) (*Operation, error)

func (*Operation) Reset

func (o *Operation) Reset()

type Order

type Order int
const (
	OrderAsc Order = iota + 1
	OrderDesc
	OrderAscNullsFirst
	OrderAscNullsLast
	OrderDescNullsFirst
	OrderDescNullsLast
)

type OrderBy

type OrderBy struct {
	Col   string
	Order Order
}

type Paging

type Paging struct {
	Type    PagingType
	Limit   string
	Offset  string
	Cursor  bool
	NoLimit bool
}

type PagingType

type PagingType int
const (
	PtOffset PagingType = iota
	PtForward
	PtBackward
)

type Parser

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

type Pos

type Pos int

Pos represents a byte position in the original input text from which this template was parsed.

type QCode

type QCode struct {
	Type      QType
	ActionVar string
	Selects   []Select
	Roots     []int32
	// contains filtered or unexported fields
}

type QType

type QType int
const (
	QTQuery QType = iota + 1
	QTMutation
	QTInsert
	QTUpdate
	QTDelete
	QTUpsert
)

func GetQType

func GetQType(gql string) QType

func (QType) String

func (qt QType) String() string

type QueryConfig

type QueryConfig struct {
	Limit            int
	Filters          []string
	Columns          []string
	DisableFunctions bool
	Block            bool
}

type Select

type Select struct {
	ID         int32
	ParentID   int32
	Args       map[string]*Node
	Name       string
	FieldName  string
	Cols       []Column
	Where      *Exp
	OrderBy    []*OrderBy
	DistinctOn []string
	Paging     Paging
	Children   []int32
	Functions  bool
	Allowed    map[string]struct{}
	PresetMap  map[string]string
	PresetList []string
	SkipRender bool
}

type Stack

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

func NewStack

func NewStack() *Stack

Create a new Stack

func (*Stack) Len

func (s *Stack) Len() int

Return the number of items in the Stack

func (*Stack) Peek

func (s *Stack) Peek() int32

View the top item on the Stack

func (*Stack) Pop

func (s *Stack) Pop() int32

Pop the top item of the Stack and return it

func (*Stack) Push

func (s *Stack) Push(value int32)

Push a value onto the top of the Stack

type TRConfig

type TRConfig struct {
	Query  QueryConfig
	Insert InsertConfig
	Update UpdateConfig
	Delete DeleteConfig
}

type UpdateConfig

type UpdateConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type ValType

type ValType int
const (
	ValStr ValType = iota + 1
	ValInt
	ValFloat
	ValBool
	ValList
	ValVar
	ValNone
	ValRef
)

Jump to

Keyboard shortcuts

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