galchemy/ast/expression
Types
pub type BinaryOperator {
Add
Subtract
Multiply
Divide
Concat
}
Constructors
-
Add -
Subtract -
Multiply -
Divide -
Concat
pub type ComparisonOp {
Eq
Neq
Gt
Gte
Lt
Lte
}
Constructors
-
Eq -
Neq -
Gt -
Gte -
Lt -
Lte
pub type Cte {
Cte(name: String, query: SelectQuery)
}
Constructors
-
Cte(name: String, query: SelectQuery)
pub type Expression {
ColumnExpr(schema.ColumnMeta)
ValueExpr(SqlValue)
StarExpr
FunctionExpr(name: String, arguments: List(Expression))
UnaryOpExpr(operator: UnaryOperator, operand: Expression)
BinaryOpExpr(
lhs: Expression,
operator: BinaryOperator,
rhs: Expression,
)
WindowExpr(function: Expression, window: WindowDefinition)
SubqueryExpr(SelectQuery)
}
Constructors
-
ColumnExpr(schema.ColumnMeta) -
ValueExpr(SqlValue) -
StarExpr -
FunctionExpr(name: String, arguments: List(Expression)) -
UnaryOpExpr(operator: UnaryOperator, operand: Expression) -
BinaryOpExpr( lhs: Expression, operator: BinaryOperator, rhs: Expression, ) -
WindowExpr(function: Expression, window: WindowDefinition) -
SubqueryExpr(SelectQuery)
pub type Order {
Order(expression: Expression, direction: OrderDirection)
}
Constructors
-
Order(expression: Expression, direction: OrderDirection)
pub type OrderDirection {
Asc
Desc
}
Constructors
-
Asc -
Desc
pub type Predicate {
Comparison(lhs: Expression, op: ComparisonOp, rhs: Expression)
And(left: Predicate, right: Predicate)
Or(left: Predicate, right: Predicate)
Not(predicate: Predicate)
InList(lhs: Expression, rhs: List(Expression))
InSubquery(lhs: Expression, rhs: SelectQuery)
IsNull(expression: Expression)
IsNotNull(expression: Expression)
Like(lhs: Expression, rhs: Expression)
Ilike(lhs: Expression, rhs: Expression)
}
Constructors
-
Comparison(lhs: Expression, op: ComparisonOp, rhs: Expression) -
-
-
Not(predicate: Predicate) -
InList(lhs: Expression, rhs: List(Expression)) -
InSubquery(lhs: Expression, rhs: SelectQuery) -
IsNull(expression: Expression) -
IsNotNull(expression: Expression) -
Like(lhs: Expression, rhs: Expression) -
Ilike(lhs: Expression, rhs: Expression)
pub type SelectItem {
SelectItem(
expression: Expression,
alias: option.Option(String),
)
}
Constructors
-
SelectItem(expression: Expression, alias: option.Option(String))
pub type SelectQuery {
SelectQuery(
ctes: List(Cte),
items: List(SelectItem),
from: option.Option(Source),
joins: List(Join),
where_: option.Option(Predicate),
group_by: List(Expression),
having_: option.Option(Predicate),
unions: List(SetOperation),
order_by: List(Order),
limit: option.Option(Int),
offset: option.Option(Int),
distinct: Bool,
)
}
Constructors
-
SelectQuery( ctes: List(Cte), items: List(SelectItem), from: option.Option(Source), joins: List(Join), where_: option.Option(Predicate), group_by: List(Expression), having_: option.Option(Predicate), unions: List(SetOperation), order_by: List(Order), limit: option.Option(Int), offset: option.Option(Int), distinct: Bool, )
pub type SetOperation {
SetOperation(kind: SetOperationKind, query: SelectQuery)
}
Constructors
-
SetOperation(kind: SetOperationKind, query: SelectQuery)
pub type SetOperationKind {
Union
UnionAll
}
Constructors
-
Union -
UnionAll
pub type Source {
TableSource(schema.Table)
DerivedSource(query: SelectQuery, alias: String)
}
Constructors
-
TableSource(schema.Table) -
DerivedSource(query: SelectQuery, alias: String)
pub type SqlValue {
Text(String)
Int(Int)
Float(Float)
Bool(Bool)
Bytea(BitArray)
Uuid(String)
Numeric(String)
Json(String)
Jsonb(String)
Enum(type_name: String, value: String)
Array(List(SqlValue))
Timestamp(timestamp.Timestamp)
Date(calendar.Date)
TimeOfDay(calendar.TimeOfDay)
Null
}
Constructors
-
Text(String) -
Int(Int) -
Float(Float) -
Bool(Bool) -
Bytea(BitArray) -
Uuid(String) -
Numeric(String) -
Json(String) -
Jsonb(String) -
Enum(type_name: String, value: String) -
Array(List(SqlValue)) -
Timestamp(timestamp.Timestamp) -
Date(calendar.Date) -
TimeOfDay(calendar.TimeOfDay) -
Null
pub type UnaryOperator {
Negate
}
Constructors
-
Negate
pub type WindowDefinition {
WindowDefinition(
partition_by: List(Expression),
order_by: List(Order),
)
}
Constructors
-
WindowDefinition( partition_by: List(Expression), order_by: List(Order), )