Documentation ¶
Overview ¶
nolint: govet
Index ¶
- Variables
- func IsReservedWord(s string) bool
- func UnquoteIdent() participle.Option
- func Visit(node Node, visitor func(node Node, next func() error) error) error
- type AST
- type AndExpression
- type Between
- type Boolean
- type Compare
- type Condition
- type ConditionExpression
- type ConditionOperand
- type ConditionRHS
- type DocumentPath
- type FunctionArgument
- type FunctionExpression
- type In
- type Node
- type NotCondition
- type Operand
- type ParenthesizedExpression
- type PathFragment
- type ProjectionColumn
- type ProjectionExpression
- type ScanDescending
- type Select
- type Value
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Lexer = lexer.Must(lexer.Regexp(`(\s+)` + `|\b(?P<Keyword>(?i)SELECT|FROM|WHERE|LIMIT|OFFSET|TRUE|FALSE|NULL|NOT|BETWEEN|AND|OR|USE|INDEX|ASC|DESC)\b` + "|(?P<QuotedIdent>`[^`]+`)" + `|(?P<Ident>[a-zA-Z_][a-zA-Z0-9_]*)` + `|(?P<Number>[-+]?\d*\.?\d+([eE][-+]?\d+)?)` + `|(?P<String>'[^']*'|"[^"]*")` + `|(?P<Operators><>|!=|<=|>=|[-+*/%:?,.()=<>\[\]])` + `|;`, )) Parser = participle.MustBuild( &AST{}, participle.Lexer(Lexer), participle.Unquote("String"), UnquoteIdent(), participle.CaseInsensitive("Keyword"), participle.UseLookahead(2), ) )
Functions ¶
func IsReservedWord ¶
IsReservedWord returns true if the string is a reserved word in DynamoDB. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html
func UnquoteIdent ¶
func UnquoteIdent() participle.Option
UnquoteIdent removes surrounding backticks (`) from quoted identifiers
Types ¶
type AndExpression ¶
type AndExpression struct {
And []*Condition `@@ ( "AND" @@ )*`
}
type Condition ¶
type Condition struct { Parenthesized *ParenthesizedExpression ` "(" @@ ")"` Not *NotCondition `| "NOT" @@` Operand *ConditionOperand `| @@` Function *FunctionExpression `| @@` }
type ConditionExpression ¶
type ConditionExpression struct {
Or []*AndExpression `@@ ( "OR" @@ )*`
}
type ConditionOperand ¶
type ConditionOperand struct { Operand *DocumentPath `@@` ConditionRHS *ConditionRHS `@@` }
type ConditionRHS ¶
type DocumentPath ¶
type DocumentPath struct {
Fragment []*PathFragment `@@ ( "." @@ )*`
}
func (DocumentPath) String ¶
func (p DocumentPath) String() string
String marshals the DocumentPath into a human readable format. Do not use this function when marshaling to expressions, because substitutions need to be applied first for reserved words.
type FunctionArgument ¶
type FunctionArgument struct { DocumentPath *DocumentPath ` @@` Value *Value `| @@` }
func (FunctionArgument) String ¶
func (a FunctionArgument) String() string
type FunctionExpression ¶
type FunctionExpression struct { Function string `@Ident` Args []*FunctionArgument `"(" @@ ( "," @@ )* ")"` }
func (*FunctionExpression) FirstArgIsRef ¶
func (f *FunctionExpression) FirstArgIsRef() bool
func (*FunctionExpression) String ¶
func (f *FunctionExpression) String() string
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node is an interface implemented by all AST nodes.
type NotCondition ¶
type NotCondition struct {
Condition *Condition `@@`
}
type Operand ¶
type Operand struct { Value *Value ` @@` SymbolRef *DocumentPath `| @@` }
type ParenthesizedExpression ¶
type ParenthesizedExpression struct {
ConditionExpression *ConditionExpression `@@`
}
type PathFragment ¶
type PathFragment struct { Symbol string `( @Ident | @QuotedIdent )` Indexes []int `( "[" @Number "]" )*` }
func (PathFragment) String ¶
func (p PathFragment) String() string
type ProjectionColumn ¶
type ProjectionColumn struct { Function *FunctionExpression ` @@` DocumentPath *DocumentPath `| @@` }
func (ProjectionColumn) String ¶
func (c ProjectionColumn) String() string
type ProjectionExpression ¶
type ProjectionExpression struct { All bool ` ( @"*" | "document" "(" @"*" ")" )` Columns []*ProjectionColumn `| @@ ( "," @@ )*` }
func (ProjectionExpression) String ¶
func (e ProjectionExpression) String() string
type ScanDescending ¶
type ScanDescending bool
func (*ScanDescending) Capture ¶
func (b *ScanDescending) Capture(values []string) error
type Select ¶
type Select struct { Projection *ProjectionExpression `@@` From string `"FROM" ( @Ident ( @"." @Ident )* | @QuotedIdent )` Index *string `( "USE" "INDEX" "(" @Ident ")" )?` Where *AndExpression `( "WHERE" @@ )?` Descending *ScanDescending `( @"ASC" | @"DESC" )?` Limit *int `( "LIMIT" @Number )?` }
Select based on http://www.h2database.com/html/grammar.html
Click to show internal directories.
Click to hide internal directories.