Documentation
¶
Index ¶
- func Equal(a, b Expr) bool
- func IsAndOperator(op Operator) bool
- func IsArithmeticOperator(op Operator) bool
- func IsComparisonOperator(op Operator) bool
- func IsInOperator(e Expr) bool
- func IsOrOperator(e Expr) bool
- type AndOp
- func (op *AndOp) Eval(ctx EvalStack) (document.Value, error)
- func (op AndOp) IsEqual(other Expr) bool
- func (op AndOp) LeftHand() Expr
- func (op AndOp) Precedence() int
- func (op AndOp) RightHand() Expr
- func (op AndOp) SetLeftHandExpr(a Expr)
- func (op AndOp) SetRightHandExpr(b Expr)
- func (op *AndOp) String() string
- func (op AndOp) Token() scanner.Token
- type Cast
- type EvalStack
- type Expr
- func Add(a, b Expr) Expr
- func And(a, b Expr) Expr
- func BitwiseAnd(a, b Expr) Expr
- func BitwiseOr(a, b Expr) Expr
- func BitwiseXor(a, b Expr) Expr
- func Div(a, b Expr) Expr
- func Eq(a, b Expr) Expr
- func GetFunc(name string, args ...Expr) (Expr, error)
- func Gt(a, b Expr) Expr
- func Gte(a, b Expr) Expr
- func In(a, b Expr) Expr
- func Is(a, b Expr) Expr
- func IsNot(a, b Expr) Expr
- func Lt(a, b Expr) Expr
- func Lte(a, b Expr) Expr
- func Mod(a, b Expr) Expr
- func Mul(a, b Expr) Expr
- func Neq(a, b Expr) Expr
- func NotIn(a, b Expr) Expr
- func Or(a, b Expr) Expr
- func Sub(a, b Expr) Expr
- type FieldSelector
- type KVPair
- type KVPairs
- type LiteralExprList
- type LiteralValue
- func ArrayValue(a document.Array) LiteralValue
- func BlobValue(v []byte) LiteralValue
- func BoolValue(v bool) LiteralValue
- func DocumentValue(d document.Document) LiteralValue
- func DoubleValue(v float64) LiteralValue
- func DurationValue(v time.Duration) LiteralValue
- func IntegerValue(v int64) LiteralValue
- func NullValue() LiteralValue
- func TextValue(v string) LiteralValue
- type NamedParam
- type Operator
- type OrOp
- func (op *OrOp) Eval(ctx EvalStack) (document.Value, error)
- func (op OrOp) IsEqual(other Expr) bool
- func (op OrOp) LeftHand() Expr
- func (op OrOp) Precedence() int
- func (op OrOp) RightHand() Expr
- func (op OrOp) SetLeftHandExpr(a Expr)
- func (op OrOp) SetRightHandExpr(b Expr)
- func (op *OrOp) String() string
- func (op OrOp) Token() scanner.Token
- type PKFunc
- type Param
- type Parentheses
- type PositionalParam
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal reports whether a and b are equal by first calling IsEqual if they have an IsEqual method with this signature:
IsEqual(Expr) bool
If not, it returns whether a and b values are equal.
func IsAndOperator ¶
IsAndOperator reports if e is the AND operator.
func IsArithmeticOperator ¶
IsArithmeticOperator returns true if e is one of +, -, *, /, %, &, |, or ^ operators.
func IsComparisonOperator ¶
IsComparisonOperator returns true if e is one of =, !=, >, >=, <, <=, IS, IS NOT, IN, or NOT IN operators.
Types ¶
type AndOp ¶
type AndOp struct {
// contains filtered or unexported fields
}
AndOp is the And operator.
func (*AndOp) Eval ¶
Eval implements the Expr interface. It evaluates a and b and returns true if both evaluate to true.
func (AndOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (AndOp) Precedence ¶
func (op AndOp) Precedence() int
func (AndOp) SetLeftHandExpr ¶
func (op AndOp) SetLeftHandExpr(a Expr)
func (AndOp) SetRightHandExpr ¶
func (op AndOp) SetRightHandExpr(b Expr)
type Cast ¶
Cast represents the CAST expression.
type EvalStack ¶
type EvalStack struct { Tx *database.Transaction Document document.Document Params []Param Info *database.TableInfo }
EvalStack contains information about the context in which the expression is evaluated. Any of the members can be nil except the transaction.
type Expr ¶
An Expr evaluates to a value.
func BitwiseAnd ¶
BitwiseAnd creates an expression thats evaluates to the result of a & b.
func BitwiseXor ¶
BitwiseXor creates an expression thats evaluates to the result of a ^ b.
type FieldSelector ¶
A FieldSelector is a ResultField that extracts a field from a document at a given path.
func (FieldSelector) Eval ¶
func (f FieldSelector) Eval(stack EvalStack) (document.Value, error)
Eval extracts the document from the context and selects the right field. It implements the Expr interface.
func (FieldSelector) IsEqual ¶
func (f FieldSelector) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (FieldSelector) Name ¶
func (f FieldSelector) Name() string
Name joins the chunks of the fields selector with the . separator.
func (FieldSelector) String ¶
func (f FieldSelector) String() string
type KVPairs ¶
type KVPairs []KVPair
KVPairs is a list of KVPair.
type LiteralExprList ¶
type LiteralExprList []Expr
LiteralExprList is a list of expressions.
func (LiteralExprList) Eval ¶
func (l LiteralExprList) Eval(stack EvalStack) (document.Value, error)
Eval evaluates all the expressions and returns a litteralValueList. It implements the Expr interface.
func (LiteralExprList) IsEqual ¶
func (l LiteralExprList) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralExprList) String ¶
func (l LiteralExprList) String() string
String implements the fmt.Stringer interface.
type LiteralValue ¶
A LiteralValue represents a litteral value of any type defined by the value package.
func ArrayValue ¶
func ArrayValue(a document.Array) LiteralValue
ArrayValue creates a litteral value of type Array.
func BlobValue ¶
func BlobValue(v []byte) LiteralValue
BlobValue creates a litteral value of type Blob.
func BoolValue ¶
func BoolValue(v bool) LiteralValue
BoolValue creates a litteral value of type Bool.
func DocumentValue ¶
func DocumentValue(d document.Document) LiteralValue
DocumentValue creates a litteral value of type Document.
func DoubleValue ¶ added in v0.7.0
func DoubleValue(v float64) LiteralValue
DoubleValue creates a litteral value of type Double.
func DurationValue ¶
func DurationValue(v time.Duration) LiteralValue
DurationValue creates a litteral value of type Duration.
func IntegerValue ¶ added in v0.7.0
func IntegerValue(v int64) LiteralValue
IntegerValue creates a litteral value of type Integer.
func TextValue ¶
func TextValue(v string) LiteralValue
TextValue creates a litteral value of type Text.
func (LiteralValue) Eval ¶
func (v LiteralValue) Eval(EvalStack) (document.Value, error)
Eval returns l. It implements the Expr interface.
func (LiteralValue) IsEqual ¶
func (v LiteralValue) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (LiteralValue) String ¶
func (v LiteralValue) String() string
String implements the fmt.Stringer interface.
type NamedParam ¶
type NamedParam string
NamedParam is an expression which represents the name of a parameter.
func (NamedParam) Eval ¶
func (p NamedParam) Eval(stack EvalStack) (document.Value, error)
Eval looks up for the parameters in the stack for the one that has the same name as p and returns the value.
func (NamedParam) IsEqual ¶
func (p NamedParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (NamedParam) String ¶
func (p NamedParam) String() string
String implements the fmt.Stringer interface.
type Operator ¶
type Operator interface { Expr Precedence() int LeftHand() Expr RightHand() Expr SetLeftHandExpr(Expr) SetRightHandExpr(Expr) Token() scanner.Token }
An Operator is a binary expression that takes two operands and executes an operation on them.
type OrOp ¶
type OrOp struct {
// contains filtered or unexported fields
}
OrOp is the And operator.
func (*OrOp) Eval ¶
Eval implements the Expr interface. It evaluates a and b and returns true if a or b evalutate to true.
func (OrOp) IsEqual ¶
Equal compares this expression with the other expression and returns true if they are equal.
func (OrOp) Precedence ¶
func (op OrOp) Precedence() int
func (OrOp) SetLeftHandExpr ¶
func (op OrOp) SetLeftHandExpr(a Expr)
func (OrOp) SetRightHandExpr ¶
func (op OrOp) SetRightHandExpr(b Expr)
type PKFunc ¶
type PKFunc struct{}
PKFunc represents the pk() function. It returns the primary key of the current document.
type Param ¶
type Param struct { // Name of the param Name string // Value is the parameter value. Value interface{} }
A Param represents a parameter passed by the user to the statement.
type Parentheses ¶ added in v0.7.0
type Parentheses struct {
E Expr
}
Parentheses is a special expression which turns any sub-expression as unary. It hides the underlying operator, if any, from the parser so that it doesn't get reordered by precedence.
type PositionalParam ¶
type PositionalParam int
PositionalParam is an expression which represents the position of a parameter.
func (PositionalParam) Eval ¶
func (p PositionalParam) Eval(stack EvalStack) (document.Value, error)
Eval looks up for the parameters in the stack for the one that is has the same position as p and returns the value.
func (PositionalParam) IsEqual ¶
func (p PositionalParam) IsEqual(other Expr) bool
IsEqual compares this expression with the other expression and returns true if they are equal.
func (PositionalParam) String ¶
func (p PositionalParam) String() string
String implements the fmt.Stringer interface.