2024-02-11 21:14:30 +00:00
|
|
|
package parsers
|
|
|
|
|
|
|
|
type SelectStmt struct {
|
2024-02-17 20:26:30 +00:00
|
|
|
SelectItems []SelectItem
|
|
|
|
Table Table
|
2024-07-17 19:40:28 +01:00
|
|
|
JoinItems []JoinItem
|
2024-02-17 20:26:30 +00:00
|
|
|
Filters interface{}
|
2024-02-27 19:10:03 +00:00
|
|
|
Distinct bool
|
2024-02-17 20:26:30 +00:00
|
|
|
Count int
|
2024-03-11 20:02:10 +00:00
|
|
|
Offset int
|
2024-02-17 20:26:30 +00:00
|
|
|
Parameters map[string]interface{}
|
|
|
|
OrderExpressions []OrderExpression
|
2024-03-11 15:50:20 +00:00
|
|
|
GroupBy []SelectItem
|
2024-02-11 21:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Table struct {
|
|
|
|
Value string
|
|
|
|
}
|
|
|
|
|
2024-07-17 19:40:28 +01:00
|
|
|
type JoinItem struct {
|
|
|
|
Table Table
|
|
|
|
SelectItem SelectItem
|
|
|
|
}
|
|
|
|
|
2024-02-18 19:29:42 +00:00
|
|
|
type SelectItemType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
SelectItemTypeField SelectItemType = iota
|
|
|
|
SelectItemTypeObject
|
|
|
|
SelectItemTypeArray
|
|
|
|
SelectItemTypeConstant
|
2024-02-18 20:37:09 +00:00
|
|
|
SelectItemTypeFunctionCall
|
2024-02-18 19:29:42 +00:00
|
|
|
)
|
|
|
|
|
2024-02-13 19:22:55 +00:00
|
|
|
type SelectItem struct {
|
|
|
|
Alias string
|
|
|
|
Path []string
|
|
|
|
SelectItems []SelectItem
|
|
|
|
Type SelectItemType
|
2024-02-18 19:29:42 +00:00
|
|
|
Value interface{}
|
2024-02-13 19:22:55 +00:00
|
|
|
IsTopLevel bool
|
2024-02-11 21:14:30 +00:00
|
|
|
}
|
|
|
|
|
2024-02-18 19:29:42 +00:00
|
|
|
type LogicalExpressionType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
LogicalExpressionTypeOr LogicalExpressionType = iota
|
|
|
|
LogicalExpressionTypeAnd
|
|
|
|
)
|
|
|
|
|
2024-02-11 21:14:30 +00:00
|
|
|
type LogicalExpression struct {
|
|
|
|
Expressions []interface{}
|
|
|
|
Operation LogicalExpressionType
|
|
|
|
}
|
|
|
|
|
|
|
|
type ComparisonExpression struct {
|
|
|
|
Left interface{}
|
|
|
|
Right interface{}
|
|
|
|
Operation string
|
|
|
|
}
|
|
|
|
|
2024-02-18 19:29:42 +00:00
|
|
|
type ConstantType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
ConstantTypeString ConstantType = iota
|
|
|
|
ConstantTypeInteger
|
|
|
|
ConstantTypeFloat
|
|
|
|
ConstantTypeBoolean
|
|
|
|
ConstantTypeParameterConstant
|
|
|
|
)
|
|
|
|
|
2024-02-11 21:14:30 +00:00
|
|
|
type Constant struct {
|
|
|
|
Type ConstantType
|
|
|
|
Value interface{}
|
|
|
|
}
|
2024-02-17 20:26:30 +00:00
|
|
|
|
2024-02-18 19:29:42 +00:00
|
|
|
type OrderDirection int
|
|
|
|
|
|
|
|
const (
|
|
|
|
OrderDirectionAsc OrderDirection = iota
|
|
|
|
OrderDirectionDesc
|
|
|
|
)
|
|
|
|
|
2024-02-17 20:26:30 +00:00
|
|
|
type OrderExpression struct {
|
|
|
|
SelectItem SelectItem
|
|
|
|
Direction OrderDirection
|
|
|
|
}
|
2024-02-18 20:37:09 +00:00
|
|
|
|
|
|
|
type FunctionCallType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
FunctionCallStringEquals FunctionCallType = "StringEquals"
|
2024-02-21 18:16:52 +00:00
|
|
|
FunctionCallConcat FunctionCallType = "Concat"
|
2024-02-21 18:25:14 +00:00
|
|
|
FunctionCallContains FunctionCallType = "Contains"
|
2024-02-21 18:46:08 +00:00
|
|
|
FunctionCallEndsWith FunctionCallType = "EndsWith"
|
|
|
|
FunctionCallStartsWith FunctionCallType = "StartsWith"
|
2024-02-22 20:12:52 +00:00
|
|
|
FunctionCallIndexOf FunctionCallType = "IndexOf"
|
2024-02-22 22:11:14 +00:00
|
|
|
FunctionCallToString FunctionCallType = "ToString"
|
2024-02-24 18:00:47 +00:00
|
|
|
FunctionCallUpper FunctionCallType = "Upper"
|
|
|
|
FunctionCallLower FunctionCallType = "Lower"
|
2024-02-24 19:24:20 +00:00
|
|
|
FunctionCallLeft FunctionCallType = "Left"
|
|
|
|
FunctionCallLength FunctionCallType = "Length"
|
|
|
|
FunctionCallLTrim FunctionCallType = "LTrim"
|
|
|
|
FunctionCallReplace FunctionCallType = "Replace"
|
|
|
|
FunctionCallReplicate FunctionCallType = "Replicate"
|
|
|
|
FunctionCallReverse FunctionCallType = "Reverse"
|
|
|
|
FunctionCallRight FunctionCallType = "Right"
|
|
|
|
FunctionCallRTrim FunctionCallType = "RTrim"
|
|
|
|
FunctionCallSubstring FunctionCallType = "Substring"
|
|
|
|
FunctionCallTrim FunctionCallType = "Trim"
|
2024-02-24 20:29:33 +00:00
|
|
|
|
|
|
|
FunctionCallIsDefined FunctionCallType = "IsDefined"
|
|
|
|
FunctionCallIsArray FunctionCallType = "IsArray"
|
|
|
|
FunctionCallIsBool FunctionCallType = "IsBool"
|
|
|
|
FunctionCallIsFiniteNumber FunctionCallType = "IsFiniteNumber"
|
|
|
|
FunctionCallIsInteger FunctionCallType = "IsInteger"
|
|
|
|
FunctionCallIsNull FunctionCallType = "IsNull"
|
|
|
|
FunctionCallIsNumber FunctionCallType = "IsNumber"
|
|
|
|
FunctionCallIsObject FunctionCallType = "IsObject"
|
|
|
|
FunctionCallIsPrimitive FunctionCallType = "IsPrimitive"
|
|
|
|
FunctionCallIsString FunctionCallType = "IsString"
|
|
|
|
|
2024-02-24 22:25:51 +00:00
|
|
|
FunctionCallArrayConcat FunctionCallType = "ArrayConcat"
|
|
|
|
FunctionCallArrayLength FunctionCallType = "ArrayLength"
|
|
|
|
FunctionCallArraySlice FunctionCallType = "ArraySlice"
|
|
|
|
FunctionCallSetIntersect FunctionCallType = "SetIntersect"
|
|
|
|
FunctionCallSetUnion FunctionCallType = "SetUnion"
|
|
|
|
|
2024-06-18 22:44:46 +01:00
|
|
|
FunctionCallMathAbs FunctionCallType = "MathAbs"
|
|
|
|
FunctionCallMathAcos FunctionCallType = "MathAcos"
|
|
|
|
FunctionCallMathAsin FunctionCallType = "MathAsin"
|
|
|
|
FunctionCallMathAtan FunctionCallType = "MathAtan"
|
|
|
|
FunctionCallMathAtn2 FunctionCallType = "MathAtn2"
|
|
|
|
FunctionCallMathCeiling FunctionCallType = "MathCeiling"
|
|
|
|
FunctionCallMathCos FunctionCallType = "MathCos"
|
|
|
|
FunctionCallMathCot FunctionCallType = "MathCot"
|
|
|
|
FunctionCallMathDegrees FunctionCallType = "MathDegrees"
|
|
|
|
FunctionCallMathExp FunctionCallType = "MathExp"
|
|
|
|
FunctionCallMathFloor FunctionCallType = "MathFloor"
|
|
|
|
FunctionCallMathIntAdd FunctionCallType = "MathIntAdd"
|
|
|
|
FunctionCallMathIntBitAnd FunctionCallType = "MathIntBitAnd"
|
|
|
|
FunctionCallMathIntBitLeftShift FunctionCallType = "MathIntBitLeftShift"
|
|
|
|
FunctionCallMathIntBitNot FunctionCallType = "MathIntBitNot"
|
|
|
|
FunctionCallMathIntBitOr FunctionCallType = "MathIntBitOr"
|
|
|
|
FunctionCallMathIntBitRightShift FunctionCallType = "MathIntBitRightShift"
|
|
|
|
FunctionCallMathIntBitXor FunctionCallType = "MathIntBitXor"
|
|
|
|
FunctionCallMathIntDiv FunctionCallType = "MathIntDiv"
|
|
|
|
FunctionCallMathIntMod FunctionCallType = "MathIntMod"
|
|
|
|
FunctionCallMathIntMul FunctionCallType = "MathIntMul"
|
|
|
|
FunctionCallMathIntSub FunctionCallType = "MathIntSub"
|
|
|
|
FunctionCallMathLog FunctionCallType = "MathLog"
|
|
|
|
FunctionCallMathLog10 FunctionCallType = "MathLog10"
|
|
|
|
FunctionCallMathNumberBin FunctionCallType = "MathNumberBin"
|
|
|
|
FunctionCallMathPi FunctionCallType = "MathPi"
|
|
|
|
FunctionCallMathPower FunctionCallType = "MathPower"
|
|
|
|
FunctionCallMathRadians FunctionCallType = "MathRadians"
|
|
|
|
FunctionCallMathRand FunctionCallType = "MathRand"
|
|
|
|
FunctionCallMathRound FunctionCallType = "MathRound"
|
|
|
|
FunctionCallMathSign FunctionCallType = "MathSign"
|
|
|
|
FunctionCallMathSin FunctionCallType = "MathSin"
|
|
|
|
FunctionCallMathSqrt FunctionCallType = "MathSqrt"
|
|
|
|
FunctionCallMathSquare FunctionCallType = "MathSquare"
|
|
|
|
FunctionCallMathTan FunctionCallType = "MathTan"
|
|
|
|
FunctionCallMathTrunc FunctionCallType = "MathTrunc"
|
|
|
|
|
2024-03-11 17:10:41 +00:00
|
|
|
FunctionCallAggregateAvg FunctionCallType = "AggregateAvg"
|
|
|
|
FunctionCallAggregateCount FunctionCallType = "AggregateCount"
|
|
|
|
FunctionCallAggregateMax FunctionCallType = "AggregateMax"
|
|
|
|
FunctionCallAggregateMin FunctionCallType = "AggregateMin"
|
|
|
|
FunctionCallAggregateSum FunctionCallType = "AggregateSum"
|
|
|
|
|
2024-02-24 20:29:33 +00:00
|
|
|
FunctionCallIn FunctionCallType = "In"
|
2024-02-18 20:37:09 +00:00
|
|
|
)
|
|
|
|
|
2024-03-11 17:10:41 +00:00
|
|
|
var AggregateFunctions = []FunctionCallType{
|
|
|
|
FunctionCallAggregateAvg,
|
|
|
|
FunctionCallAggregateCount,
|
|
|
|
FunctionCallAggregateMax,
|
|
|
|
FunctionCallAggregateMin,
|
|
|
|
FunctionCallAggregateSum,
|
|
|
|
}
|
|
|
|
|
2024-02-18 20:37:09 +00:00
|
|
|
type FunctionCall struct {
|
|
|
|
Arguments []interface{}
|
|
|
|
Type FunctionCallType
|
|
|
|
}
|