predicate

package
v0.14.27 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewZitiqlParseError

func NewZitiqlParseError(tn *antlr.TerminalNode, msg string) zitiql.ParseError

func ParseWhereClause

func ParseWhereClause(str string, imap *IdentifierMap) (squirrel.Sqlizer, []error)

Types

type Between

type Between binaryOp

func (Between) ToSql

func (b Between) ToSql() (string, []interface{}, error)

type ConjType

type ConjType string
const (
	AndConj ConjType = "AND"
	OrConj  ConjType = "OR"
)

type Contains

type Contains unaryOp

func (Contains) ToSql

func (c Contains) ToSql() (string, []interface{}, error)

type Direction

type Direction string
const (
	ASC  Direction = "ASC"
	DESC Direction = "DESC"
)

type IdentifierMap

type IdentifierMap map[string]string

func (*IdentifierMap) Fields

func (im *IdentifierMap) Fields() []string

type IdentifierOps

type IdentifierOps map[string]OpSet

func (*IdentifierOps) Merge

func (io *IdentifierOps) Merge(io2 *IdentifierOps)

type IdentifierTranslations

type IdentifierTranslations map[string]string

type InSubSelect

type InSubSelect struct {
	Column string
	Select squirrel.SelectBuilder
}

func (InSubSelect) ToSql

func (ss InSubSelect) ToSql() (string, []interface{}, error)

type NotBetween

type NotBetween binaryOp

func (NotBetween) ToSql

func (b NotBetween) ToSql() (string, []interface{}, error)

type NotContains

type NotContains unaryOp

func (NotContains) ToSql

func (c NotContains) ToSql() (string, []interface{}, error)

type OpSet

type OpSet map[OpType]bool

func (*OpSet) Merge

func (os *OpSet) Merge(os2 *OpSet)

type OpType

type OpType string
const (
	EqOp          OpType = "="
	NeqOp         OpType = "!="
	BetweenOp     OpType = "BETWEEN"
	NotBetweenOp  OpType = "NOT BETWEEN"
	InOp          OpType = "IN"
	NotInOp       OpType = "NOT IN"
	ContainsOp    OpType = "CONTAINS"
	NotContainsOp OpType = "NOT CONTAINS"
	LtOp          OpType = "<"
	LtEOp         OpType = "<="
	GtOp          OpType = ">"
	GtEOp         OpType = ">="
)

type Paging

type Paging struct {
	Offset    int64
	Limit     int64
	ReturnAll bool
}

func (*Paging) String

func (paging *Paging) String() string

type ParseError

type ParseError struct {
	Line    int    `json:"line"`
	Column  int    `json:"column"`
	Symbol  string `json:"symbol"`
	Message string `json:"message"`
}

func NewParseError

func NewParseError(pe *zitiql.ParseError) *ParseError

func (*ParseError) Error

func (e *ParseError) Error() string

type Predicate

type Predicate struct {
	Clause   squirrel.Sqlizer
	Callback func(db *gorm.DB) *gorm.DB
}

func (*Predicate) Apply

func (p *Predicate) Apply(q *gorm.DB) *gorm.DB

type ResolverType

type ResolverType string
const (
	ConjResolver  ResolverType = "CONJ"
	GroupResolver ResolverType = "GROUP"
	OpResolver    ResolverType = "OP"
)

type Sort

type Sort []SortField

func ParseOrderBy

func ParseOrderBy(str string, imap *IdentifierMap) (*Sort, error)

func (*Sort) Parts

func (s *Sort) Parts() []string

type SortField

type SortField struct {
	Field     string
	Direction Direction
}

func (*SortField) String

func (sf *SortField) String() string

type ToSquirrelListener

type ToSquirrelListener struct {
	*zitiql.BaseZitiQlListener

	Predicate         squirrel.Sqlizer
	PrintRuleLocation bool
	PrintChildren     bool
	IdentifierOps     IdentifierOps

	IdentifierErrors []zitiql.ParseError
	// contains filtered or unexported fields
}

func NewSquirrelListener

func NewSquirrelListener() *ToSquirrelListener

func NewSquirrelListenerWithMap

func NewSquirrelListenerWithMap(identifierMap *IdentifierMap) *ToSquirrelListener

func (*ToSquirrelListener) EnterAndConjunction

func (z *ToSquirrelListener) EnterAndConjunction(c *zitiql.AndConjunctionContext)

EnterAndConjunction is called when entering the AndConjunction production.

func (*ToSquirrelListener) EnterBetweenDateOp

func (z *ToSquirrelListener) EnterBetweenDateOp(c *zitiql.BetweenDateOpContext)

EnterBetweenDateOp is called when entering the BetweenDateOp production.

func (*ToSquirrelListener) EnterBetweenNumberOp

func (z *ToSquirrelListener) EnterBetweenNumberOp(c *zitiql.BetweenNumberOpContext)

EnterBetweenNumberOp is called when entering the BetweenNumberOp production.

func (*ToSquirrelListener) EnterBinaryContainsOp

func (z *ToSquirrelListener) EnterBinaryContainsOp(c *zitiql.BinaryContainsOpContext)

EnterBinaryContainsOp is called when entering the BinaryContainsOp production.

func (*ToSquirrelListener) EnterBinaryEqualToBoolOp

func (z *ToSquirrelListener) EnterBinaryEqualToBoolOp(c *zitiql.BinaryEqualToBoolOpContext)

EnterBinaryEqualToBoolOp is called when entering the BinaryEqualToBoolOp production.

func (*ToSquirrelListener) EnterBinaryEqualToDatetimeOp

func (z *ToSquirrelListener) EnterBinaryEqualToDatetimeOp(c *zitiql.BinaryEqualToDatetimeOpContext)

EnterBinaryEqualToDatetimeOp is called when entering the BinaryEqualToDatetimeOp production.

func (*ToSquirrelListener) EnterBinaryEqualToNullOp

func (z *ToSquirrelListener) EnterBinaryEqualToNullOp(c *zitiql.BinaryEqualToNullOpContext)

EnterBinaryEqualToNullOp is called when entering the BinaryEqualToNullOp production.

func (*ToSquirrelListener) EnterBinaryEqualToNumberOp

func (z *ToSquirrelListener) EnterBinaryEqualToNumberOp(c *zitiql.BinaryEqualToNumberOpContext)

EnterBinaryEqualToNumberOp is called when entering the BinaryEqualToNumberOp production.

func (*ToSquirrelListener) EnterBinaryEqualToStringOp

func (z *ToSquirrelListener) EnterBinaryEqualToStringOp(c *zitiql.BinaryEqualToStringOpContext)

EnterBinaryEqualToStringOp is called when entering the BinaryEqualToStringOp production.

func (*ToSquirrelListener) EnterBinaryGreaterThanDatetimeOp

func (z *ToSquirrelListener) EnterBinaryGreaterThanDatetimeOp(c *zitiql.BinaryGreaterThanDatetimeOpContext)

EnterBinaryGreaterThanDatetimeOp is called when entering the BinaryGreaterThanDatetimeOp production.

func (*ToSquirrelListener) EnterBinaryGreaterThanNumberOp

func (z *ToSquirrelListener) EnterBinaryGreaterThanNumberOp(c *zitiql.BinaryGreaterThanNumberOpContext)

EnterBinaryGreaterThanNumberOp is called when entering the BinaryGreaterThanNumberOp production.

func (*ToSquirrelListener) EnterBinaryLessThanDatetimeOp

func (z *ToSquirrelListener) EnterBinaryLessThanDatetimeOp(c *zitiql.BinaryLessThanDatetimeOpContext)

EnterBinaryLessThanDatetimeOp is called when entering the BinaryLessThanDatetimeOp production.

func (*ToSquirrelListener) EnterBinaryLessThanNumberOp

func (z *ToSquirrelListener) EnterBinaryLessThanNumberOp(c *zitiql.BinaryLessThanNumberOpContext)

EnterBinaryLessThanNumberOp is called when entering the BinaryLessThanNumberOp production.

func (*ToSquirrelListener) EnterEnd

func (z *ToSquirrelListener) EnterEnd(c *zitiql.EndContext)

EnterEnd is called when entering the End production.

func (*ToSquirrelListener) EnterGroup

func (z *ToSquirrelListener) EnterGroup(c *zitiql.GroupContext)

EnterGroup is called when entering the Group production.

func (*ToSquirrelListener) EnterInDatetimeArrayOp

func (z *ToSquirrelListener) EnterInDatetimeArrayOp(c *zitiql.InDatetimeArrayOpContext)

EnterInDatetimeArrayOp is called when entering the InDatetimeArrayOp production.

func (*ToSquirrelListener) EnterInNumberArrayOp

func (z *ToSquirrelListener) EnterInNumberArrayOp(c *zitiql.InNumberArrayOpContext)

EnterInNumberArrayOp is called when entering the InNumberArrayOp production.

func (*ToSquirrelListener) EnterInStringArrayOp

func (z *ToSquirrelListener) EnterInStringArrayOp(c *zitiql.InStringArrayOpContext)

EnterInStringArrayOp is called when entering the InStringArrayOp production.

func (*ToSquirrelListener) EnterOperationOp

func (z *ToSquirrelListener) EnterOperationOp(c *zitiql.OperationOpContext)

EnterOperationOp is called when entering the OperationOp production.

func (*ToSquirrelListener) EnterOrConjunction

func (z *ToSquirrelListener) EnterOrConjunction(c *zitiql.OrConjunctionContext)

EnterOrConjunction is called when entering the OrConjunction production.

func (*ToSquirrelListener) ExitAndConjunction

func (z *ToSquirrelListener) ExitAndConjunction(c *zitiql.AndConjunctionContext)

ExitAndConjunction is called when exiting the AndConjunction production.

func (*ToSquirrelListener) ExitBetweenDateOp

func (z *ToSquirrelListener) ExitBetweenDateOp(c *zitiql.BetweenDateOpContext)

ExitBetweenDateOp is called when exiting the BetweenDateOp production.

func (*ToSquirrelListener) ExitBetweenNumberOp

func (z *ToSquirrelListener) ExitBetweenNumberOp(c *zitiql.BetweenNumberOpContext)

ExitBetweenNumberOp is called when exiting the BetweenNumberOp production.

func (*ToSquirrelListener) ExitBinaryContainsOp

func (z *ToSquirrelListener) ExitBinaryContainsOp(c *zitiql.BinaryContainsOpContext)

ExitBinaryContainsOp is called when exiting the BinaryContainsOp production.

func (*ToSquirrelListener) ExitBinaryEqualToBoolOp

func (z *ToSquirrelListener) ExitBinaryEqualToBoolOp(c *zitiql.BinaryEqualToBoolOpContext)

ExitBinaryEqualToBoolOp is called when exiting the BinaryEqualToBoolOp production.

func (*ToSquirrelListener) ExitBinaryEqualToDatetimeOp

func (z *ToSquirrelListener) ExitBinaryEqualToDatetimeOp(c *zitiql.BinaryEqualToDatetimeOpContext)

ExitBinaryEqualToDatetimeOp is called when exiting the BinaryEqualToDatetimeOp production.

func (*ToSquirrelListener) ExitBinaryEqualToNullOp

func (z *ToSquirrelListener) ExitBinaryEqualToNullOp(c *zitiql.BinaryEqualToNullOpContext)

ExitBinaryEqualToNullOp is called when exiting the BinaryEqualToNullOp production.

func (*ToSquirrelListener) ExitBinaryEqualToNumberOp

func (z *ToSquirrelListener) ExitBinaryEqualToNumberOp(c *zitiql.BinaryEqualToNumberOpContext)

ExitBinaryEqualToNumberOp is called when exiting the BinaryEqualToNumberOp production.

func (*ToSquirrelListener) ExitBinaryEqualToStringOp

func (z *ToSquirrelListener) ExitBinaryEqualToStringOp(c *zitiql.BinaryEqualToStringOpContext)

ExitBinaryEqualToStringOp is called when exiting the BinaryEqualToStringOp production.

func (*ToSquirrelListener) ExitBinaryGreaterThanDatetimeOp

func (z *ToSquirrelListener) ExitBinaryGreaterThanDatetimeOp(c *zitiql.BinaryGreaterThanDatetimeOpContext)

ExitBinaryGreaterThanDatetimeOp is called when exiting the BinaryGreaterThanDatetimeOp production.

func (*ToSquirrelListener) ExitBinaryGreaterThanNumberOp

func (z *ToSquirrelListener) ExitBinaryGreaterThanNumberOp(c *zitiql.BinaryGreaterThanNumberOpContext)

ExitBinaryGreaterThanNumberOp is called when exiting the BinaryGreaterThanNumberOp production.

func (*ToSquirrelListener) ExitBinaryLessThanDatetimeOp

func (z *ToSquirrelListener) ExitBinaryLessThanDatetimeOp(c *zitiql.BinaryLessThanDatetimeOpContext)

ExitBinaryLessThanDatetimeOp is called when exiting the BinaryLessThanDatetimeOp production.

func (*ToSquirrelListener) ExitBinaryLessThanNumberOp

func (z *ToSquirrelListener) ExitBinaryLessThanNumberOp(c *zitiql.BinaryLessThanNumberOpContext)

ExitBinaryLessThanNumberOp is called when exiting the BinaryLessThanNumberOp production.

func (*ToSquirrelListener) ExitEnd

func (z *ToSquirrelListener) ExitEnd(c *zitiql.EndContext)

ExitEnd is called when exiting the End production.

func (*ToSquirrelListener) ExitGroup

func (z *ToSquirrelListener) ExitGroup(c *zitiql.GroupContext)

ExitGroup is called when exiting the Group production.

func (*ToSquirrelListener) ExitInDatetimeArrayOp

func (z *ToSquirrelListener) ExitInDatetimeArrayOp(c *zitiql.InDatetimeArrayOpContext)

ExitInDatetimeArrayOp is called when exiting the InDatetimeArrayOp production.

func (*ToSquirrelListener) ExitInNumberArrayOp

func (z *ToSquirrelListener) ExitInNumberArrayOp(c *zitiql.InNumberArrayOpContext)

ExitInNumberArrayOp is called when exiting the InNumberArrayOp production.

func (*ToSquirrelListener) ExitInStringArrayOp

func (z *ToSquirrelListener) ExitInStringArrayOp(c *zitiql.InStringArrayOpContext)

ExitInStringArrayOp is called when exiting the InStringArrayOp production.

func (*ToSquirrelListener) ExitOperationOp

func (z *ToSquirrelListener) ExitOperationOp(c *zitiql.OperationOpContext)

ExitOperationOp is called when exiting the OperationOp production.

func (*ToSquirrelListener) ExitOrConjunction

func (z *ToSquirrelListener) ExitOrConjunction(c *zitiql.OrConjunctionContext)

ExitOrConjunction is called when exiting the OrConjunction production.

func (*ToSquirrelListener) HandleError

func (z *ToSquirrelListener) HandleError(err error)

type ValueType

type ValueType string
const (
	StringType        ValueType = "STRING"
	NumberType        ValueType = "NUMBER"
	DatetimeType      ValueType = "DATETIME"
	BoolType          ValueType = "BOOL"
	NullType          ValueType = "NULL"
	StringArrayType   ValueType = "STRING_ARRAY"
	NumberArrayType   ValueType = "NUMBER_ARRAY"
	DatetimeArrayType ValueType = "DATETIME_ARRAY"
)

Jump to

Keyboard shortcuts

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